SQLIntermediate#joins#queries

How do you find records in table A that are missing in table B?

Use a LEFT JOIN with an IS NULL check on the right side, or NOT EXISTS. Avoid NOT IN when the subquery can return NULL.

Example
SELECT c.*
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.id IS NULL;

Related Questions

1
SQLBeginner#datatypes

CHAR vs VARCHAR vs TEXT?

Open
2
SQLAdvanced#performance

What is the difference between an execution plan and EXPLAIN ANALYZE?

Open
3
SQLAdvanced#performance

How do you optimise a slow SQL query?

Open