Beginner Case 19 of 50

Case 019: Audio Buyers

customersordersorder_itemsproducts

Marketing is planning an audio-gear promotion, and the manager passes along their request.

"Could you pull a list of everyone who's ever bought anything from the Audio category? I just need to know who they are — not what they bought."

The data Alex is looking at

customers
idnamecountrysignup_date
1SamGermany2026-01-02
2NinaCanada2026-01-05
3DavidGermany2026-01-10
4MayaJapan2026-01-15
5DanielCanada2026-01-20
… 5 more rows
orders
idcustomer_idorder_date
10112026-01-05
10222026-01-08
10332026-01-12
10412026-01-20
10542026-02-01
… 23 more rows
order_items
order_idproduct_idquantity
10112
10121
10231
10323
10451
… 29 more rows
products
idnamecategoryprice
1KeyboardAccessories2500
2MouseAccessories1200
3HeadphonesAudio3500
4MonitorDisplays12000
5LaptopComputers60000
… 5 more rows
TASK

Help Alex answer the manager:

“Find every customer who has bought at least one product from the 'Audio' category.”
SQL editor Ctrl+Enter to run
Write a query above and hit Run to see what comes back.
No hints requested yet — click "Get a hint" when you're stuck.
Alex's final query — this is for reference. Copy it into your own thinking, not into the editor above.
SELECT customers.name FROM customers WHERE EXISTS ( SELECT 1 FROM orders JOIN order_items ON order_items.order_id = orders.id JOIN products ON products.id = order_items.product_id WHERE orders.customer_id = customers.id AND products.category = 'Audio' );
What that query returns
Case Debrief EXISTS
  • EXISTS is a fast, readable way to ask "does at least one matching row exist?" without joining and risking duplicate rows.

Case closed.

Ready for the next one?

Next: Case 020 — Never Bought Accessories →