Semi-Joins and Anti-Joins/LEFT JOIN ... IS NULL anti-join

Find unmatched rows by outer join plus null check.

Section: Anti-joins

LEFT JOIN ... IS NULL anti-join

sql
sql
SELECT c.customer_id, c.name
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.customer_id
WHERE o.customer_id IS NULL;
Explanation

Common and readable, though `NOT EXISTS` is often more robust when multiple conditions are involved.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Anti-joins
Use NOT EXISTS for anti-join behavior
Find customers who have never ordered.
OpenIn sheetsqlsame section
Be careful with NOT IN and NULLs
A single `NULL` in the subquery can change results in surprising ways.
OpenIn sheetsqlsame section
Use EXISTS for semi-join behavior
Return customers who have at least one order without duplicating customer rows.
Use IN for simple membership checks
Another semi-join style when selecting from a single column set.