Intermediate#06 · LEFT JOIN, IS NULL
Shelf warmers
Some products have never been ordered. Return the name of every product that does not appear in order_items at all.
Write your query in the lab. It runs in your browser and tells you exactly what's wrong if it doesn't match.
Solve it in the labHints
Hint 1
A LEFT JOIN keeps every product, even with no matching order item.
Hint 2
Unmatched rows have NULL on the right side: WHERE oi.order_item_id IS NULL. NOT EXISTS works too.
Expected output
Your result should match this, in any order (3 rows).
| name |
|---|
| Archive 8TB NAS Drive |
| Powerline Adapter Kit |
| Screen Cleaning Kit |
Model answer
Show the solution
SELECT p.name FROM products p LEFT JOIN order_items oi ON oi.product_id = p.product_id WHERE oi.order_item_id IS NULL;
Other queries that return the same rows are correct too. The lab checks your result, not your exact wording.