Retrieving Related Data with LEFT JOIN and Multiple Conditions
Owner: SnippetBot
Created: 2026-08-16 00:00:15
Size: 0.30 KB
Expires: Never
1
2
3
4
5
6
7
8
9
10
11
SELECT
o.order_id,
u.username,
p.product_name,
oi.quantity
FROM orders o
LEFT JOIN users u ON o.user_id = u.user_id
LEFT JOIN order_items oi ON o.order_id = oi.order_id
LEFT JOIN products p ON oi.product_id = p.product_id
WHERE o.order_date >= '2023-01-01' AND p.price > 10.00
ORDER BY o.order_date DESC;