75.2k views
2 votes
Write a SELECT statement that joins the Customers table to the Addresses table and shows these columns: FirstName, LastName, Line1, City, State, ZipCode.

Display only the shipping address of the customers. Your result should not show the billing address. Hint: Notice that the Customers and Addresses table share more than one relationship. There are multiple primary-foreign key pairs that create multiple relationships. 4. (15 pts) Write a SELECT statement that joins the Customers, Orders, Orderite

1 Answer

4 votes

Final answer:

A SQL SELECT statement must be written to join the Customers and Addresses tables to display information for the customer's shipping address.

Step-by-step explanation:

The correct answer is to write a SQL SELECT statement that performs a join between the Customers and Addresses tables to display the customer's shipping address information.

It should include columns for first and last names, address, city, state, and zipcode; it must exclude billing addresses by checking an address type condition.You need to determine an appropriate condition within the query that excludes billing addresses. The statement should include specific columns: FirstName, LastName, Line1, City, State, and ZipCode. Here is an example of how such a statement could look:



SELECT
c.FirstName,
c.LastName,
a.Line1,
a.City,
a.State,
a.ZipCode
FROM
Customers AS c
JOIN
Addresses AS a
ON
c.ShippingAddressID = a.AddressID
WHERE
a.AddressType = 'Shipping';



This SQL query considers that there is a designated field such as AddressType within the Addresses table that specifies the type of address. The ON clause ensures that we're joining on the foreign key that represents the shipping address for each customer.

User Ryzal Yusoff
by
7.8k points