16.5k views
2 votes
Write a SELECT statement that joins the Customers table to the Addresses table and returns these columns: FirstName, LastName, Line1, City, State, ZipCode. Return one row for each customer, but only return addresses that are the shipping address for a customer.

User SpkingR
by
7.4k points

1 Answer

3 votes

Answer:

SELECT [FirstName], LastName,

Line1, City, [State], ZipCode

FROM Customers JOIN Addresses ON

Customers.CustomerID = Addresses.CustomerID

AND

Customers.ShippingAddressID = Addresses.AddressID

Step-by-step explanation:

The SELECT statement allows us to list the names of columns we wish to choose or select from the table. The customer and address tables are joined based on the common column which harbors unique ID and Address for each customer, CustomerID present in both tables (customers and addresses) and Shipping Address present as ShippingAddressID in Customers and AddressID in Addresses.

User Ankon
by
7.3k points