SQL Queries in MySQL **This is using the Sakila Sample database which can downlo
ID: 3931028 • Letter: S
Question
SQL Queries in MySQL
**This is using the Sakila Sample database which can downloaded here: https://dev.mysql.com/doc/sakila/en/ **
Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include the city or postal code for this question). Next, write a query that only lists the customers who are inactive, and include the city, country, postal code for each customer as well.
**Note that you will be performing a query on multiple tables.**
Explanation / Answer
Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table.
SELECT last_name, first_name, address, district, phone FROM CUSTOMER C, ADDRESS A WHERE C.address_id = A.address_id
Write a query that only lists the customers who are inactive, and include the city, country, postal code for each customer as well.
SELECT last_name, first_name, city, country, postal_code FROM CUSTOMER C, ADDRESS A, CITY CT, COUNTRY CRY WHERE C.address_id = A.address_id AND A.city_id = CT.city_id AND CT.country_id = CRT.country_id
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.