Learn SQL Lesson
Finding Missing Matches
One common use of `LEFT JOIN` is to find rows that do not have a match.
Start with the table you want to keep, `LEFT JOIN` the related table, then filter to rows where the right side is `NULL`.
For example, to find departments without employees:
SELECT d.name AS department_name
FROM departments AS d
LEFT JOIN employees AS e
ON d.id = e.department_id
WHERE e.id IS NULL
This pattern is very useful for spotting missing data and gaps in relationships.
Practice challenge
Find departments that do not currently have any employees. Return department_name.