Blog · Guide
How to JOIN Three Tables in SQL
Chain JOINs to answer real shop questions: who bought what. Step-by-step with orders, customers, and products.
One relationship at a time
Don’t try to invent a mega-ON that links everything at once. Join table A to B, then attach C to the result.
FROM orders o JOIN customers c ON o.customer_id = c.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN products p ON oi.product_id = p.product_id
Aliases keep it readable
Short aliases (o, c, oi, p) prevent orders.order_id soup. Same style we use in the intermediate drills.
Try it yourself
The fastest way to lock this in is a short drill on the same Northstar Market tables.