FROM orders JOIN customers ON customers.id = orders.customer_id pairs each order with its customer. INNER JOIN keeps only rows that match on both sides.
Give tables short aliases (o, c) and always write the ON condition: a join without it pairs every row with every other row.
Worked example
Show the first orders with the customer who placed them.
SELECT o.id, o.order_date, c.name FROM orders o JOIN customers c ON c.id = o.customer_id ORDER BY o.id LIMIT 5;
| id | order_date | name |
|---|---|---|
| 1 | 2026-05-17 | Maria Papadopoulou |
| 2 | 2026-04-20 | Maria Papadopoulou |
| 3 | 2026-06-17 | Maria Papadopoulou |
| 4 | 2026-01-28 | Maria Papadopoulou |
| 5 | 2026-08-24 | Jonas Becker |
Common mistakes
- Forgetting the ON condition.
- Summing order totals after joining order lines, which counts each order once per line.