Chapter Two – Introduction to Structured Query Language
Page 2-124
U. Show the LastName, FirstName, Phone, and ItemDescription for customers who have
bought an Item named ‘Desk Lamp‘. Also show the LastName, FirstName, and Phone of
all the other customers. Present results sorted by Item in ascending order, then
LastName in ascending order, and then FirstName in descending order. HINT: In
Microsoft Access 2016 you will either need to use a UNION statement or a sequence of
two queries to solve this, because Microsoft Access disallows nesting an INNER join
inside a LEFT or RIGHT join. The other DBMS products can do it with one query (not a
UNION statement).
Solutions to The Queen Anne Curiosity Shop questions are contained in the Microsoft Access
The LEFT JOIN solution for Oracle Database, MySQL, and SQL Server:
SELECT LastName, FirstName, Phone, ItemDescription
FROM CUSTOMER LEFT JOIN (SALE
JOIN SALE_ITEM
ON SALE.SaleID = SALE_ITEM.SaleID
JOIN ITEM
ON SALE_ITEM.ItemID = ITEM.ItemID