Multiple JOINs
Chain more than two tables together.
Questions this answers
- →How do I join three or more tables?
- →How do I get order details including the product and customer?
- →Does the order of JOINs matter?
How it works
You can chain as many JOINs as you need. Each JOIN adds another table to the query. The order matters for LEFT JOINs (the "left" table in each JOIN is what you've built so far), but INNER JOINs are commutative — the optimizer will reorder them as needed.
Three-table join
SELECT customers.name, orders.id AS order_id, products.name AS product FROM orders JOIN customers ON orders.customer_id = customers.id JOIN order_items ON order_items.order_id = orders.id JOIN products ON order_items.product_id = products.id;
Mixing JOIN types
SELECT customers.name, orders.total, coupons.code FROM customers JOIN orders ON orders.customer_id = customers.id LEFT JOIN coupons ON orders.coupon_id = coupons.id;
💡 LEFT JOIN on coupons means customers without coupons still appear with NULL for coupons.code.
Ready to practise Multiple JOINs?
Solve real exercises with AI feedback — free to start.
Try it free →