pbPassingBI
/

How do you find rows in one table with no match in another?

beginner
Answer

The safest form is NOT EXISTS with a correlated subquery — it is NULL-safe and never multiplies rows.

LEFT JOIN … WHERE right.key IS NULL is the classic anti-join and works well, and is often the fastest on large sets.

Avoid NOT IN against a subquery that can return NULL: a single NULL makes every comparison unknown and the query returns no rows at all, with no error.

Related