Part 68: Multi-Table Joins: Joining 3 or More Tables
Real-world business queries span multiple normalized tables.
1. Complete E-Commerce Order Details Query
SELECT
o.id AS order_id,
u.first_name || ' ' || u.last_name AS customer_name,
p.name AS product_name,
oi.quantity,
oi.unit_price,
(oi.quantity * oi.unit_price) AS line_total
FROM orders o
JOIN users u ON o.user_id = u.id
JOIN order_items oi ON o.id = oi.order_id
JOIN products p ON oi.product_id = p.id
WHERE o.status = 'shipped'
ORDER BY o.id, line_total DESC;
Key Takeaways
- Chain joins sequentially following foreign key relationships.
In Part 69, we explore Non-Equi Joins: Joining on Ranges and Inequalities!

