Joining Three or More Tables
Real questions often need more than two tables. Keep adding JOINs, one per table, each with its own ON.
In the E-commerce database, an order has items, and each item points to a product:
- orders: one row per order
- order_items: one row per product in an order
- products: names and prices
Which products were in each order?
Add customers to see who bought what:
Each JOIN connects the new table to one already in the query. Follow the keys like a path: customers → orders → order_items → products.
Check your understanding
Which query lists each customer's name next to the products they ordered?
Examples run on the employees sample database. Open any of them in the playground to experiment.