Left Join Person and Address Tables
You have two tables named 'Person' and 'Address'. The 'Person' table contains personId, lastName, and firstName, while the 'Address' table contains addressId, personId, city, and state. Write a SQL query to report each person's first name, last name, city, and state. If a person does not have an address, include the person with NULL values for city and state.
sql
SELECT Person.firstName, Person.lastName, Address.city, Address.state FROM Person LEFT JOIN Address ON Person.personId = Address.personId;
This query performs a LEFT JOIN between the Person and Address tables on the personId column to retrieve the specified columns, ensuring that all records from the Person table are included even when no matching address record exists.
PromptDB can make mistakes. Please double-check responses.