Question 7: You have three tables in a database named Company, Person, and Addre
ID: 3652248 • Letter: Q
Question
Question 7: You have three tables in a database named Company, Person, and Address. Each table has a large num-ber of columns.The Company table has a column named CompanyID and another column named CEO. CEO is a foreign key to the Per-son table and it represents the CEO of the company.
The Person table has a column named PersonID and another column named Address. The Address column is a foreign key to the Address table. It represents where that person lives.
The Address table has a column named AddressId and another column named City, which is a varchar field of some arbitrary length. The City column represents the city for a particular address.
Given a company with CompanyId = X, write a select statement that will tell me the name of the city that the CEO of that company lives in.
Explanation / Answer
Please rate it:
You did not mention the attributes of the 3 tables fully; I assumed that CEO of Company is referencing a variable CEO in Persons & made the join between them . Please put your end attributes in joining these 2 tables;
select A.city from Company C, Person P, Address A where C.CEO=P.CEO AND P.Address=A.Address AND companyId='x'
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.