When an OUTER JOIN finds no matching row, columns from the unmatched side can contain NULL. Checking these NULL values can identify missing relationships.
Finding records without relationships is essential for reconciliation, exception reporting, and data-quality checks.
Find customers who have never placed an order.
SELECT
c.CustomerID,
c.CustomerName
FROM Customers c
LEFT JOIN Orders o
ON c.CustomerID = o.CustomerID
WHERE o.OrderID IS NULL;
Used in customer analysis, reconciliation, compliance, and data-quality reporting.
- OUTER JOINs can produce NULL values for unmatched rows.
- IS NULL can identify missing relationships.
- LEFT JOIN plus IS NULL is a common ANTI JOIN pattern.
- NULL checks are useful for reconciliation.
- The checked column should normally come from the right table.
How can you find unmatched records with LEFT JOIN?
Use LEFT JOIN and filter for NULL values in a required column from the right-side table.
Why use IS NULL instead of = NULL?
NULL represents an unknown or missing value, so SQL requires IS NULL for NULL comparison.