WHERE city = NULL returns nothing; WHERE city IS NULL finds the gaps. Use IS NOT NULL for the opposite.
COALESCE(city, 'Unknown') replaces missing values in the output. Aggregates such as SUM and AVG skip NULLs, while COUNT(*) counts every row.
Worked example
Which customers have no city recorded?
SELECT name, country FROM customers WHERE city IS NULL;
| name | country |
|---|---|
| Lucas Martin | France |
| Ciara Walsh | Ireland |
Common mistakes
- Writing = NULL instead of IS NULL.
- Forgetting that COUNT(column) ignores NULLs while COUNT(*) does not.