Beginner Case 6 of 50

Case 006: Whose Order Is This?

orderscustomers

The orders table only has customer IDs, not names.

"I can't read IDs," the manager says. "Could you pull the actual names instead?"

The data Alex is looking at

orders
idcustomer_idproductamountorder_date
1011Keyboard25002026-01-05
1023Mouse12002026-01-08
1032Headphones35002026-01-10
1044Monitor120002026-01-12
1051Webcam45002026-02-03
… 4 more rows
customers
idnamecountry
1SamGermany
2NinaCanada
3DavidBrazil
4MayaJapan
5DanielAustralia
… 1 more row
TASK

Help Alex answer the manager:

“List every order together with the name and country of the customer who placed it.”
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, customers.country, orders.product, orders.amount FROM orders JOIN customers ON orders.customer_id = customers.id;
What that query returns
Case Debrief INNER JOIN
  • JOIN combines rows from two tables using a shared key — here, customer_id links orders back to who placed them.
  • Worth knowing: customers.id is a primary key (uniquely identifies each row); orders.customer_id is a foreign key (points back to another table's primary key).
  • That relationship is what every JOIN actually runs on.

Case closed.

Ready for the next one?

Next: Case 007 — The Customers Who Never Ordered →