Lesson 13 / 30
LEFT & RIGHT JOIN
Keep unmatched rows with LEFT and RIGHT JOIN, and find records with no match using IS NULL.
By Rahul Agarwal · 15 years in web development · Updated 1 Oct 2026
LEFT JOIN
LEFT JOIN keeps every row from the left table, filling unmatched right-side columns with NULL.
SELECT c.name, o.id AS order_id
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id;
Output:
name | order_id Asha Rao | 1 Rahul Mehta | 2 Priya Nair | NULL
RIGHT JOIN
RIGHT JOIN is the mirror of LEFT JOIN — it keeps every row from the right table instead. Most people just swap table order and use LEFT JOIN.
Finding unmatched rows
Add WHERE o.id IS NULL after a LEFT JOIN to find customers with no orders at all.