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
| id | customer_id | product | amount | order_date |
|---|---|---|---|---|
| 101 | 1 | Keyboard | 2500 | 2026-01-05 |
| 102 | 3 | Mouse | 1200 | 2026-01-08 |
| 103 | 2 | Headphones | 3500 | 2026-01-10 |
| 104 | 4 | Monitor | 12000 | 2026-01-12 |
| 105 | 1 | Webcam | 4500 | 2026-02-03 |
| … 4 more rows | ||||
customers
| id | name | country |
|---|---|---|
| 1 | Sam | Germany |
| 2 | Nina | Canada |
| 3 | David | Brazil |
| 4 | Maya | Japan |
| 5 | Daniel | Australia |
| … 1 more row | ||
TASK
Help Alex answer the manager:
“List every order together with the name and country of the customer who placed it.”
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.