Lesson 7 / 37 · Conditions and NULL

Testing for NULL needs IS NULL

Farid has no region. region_id = NULL is never TRUE, because anything compared with NULL is unknown, even NULL itself. IS NULL is the only test that sees it.

The query

SELECT name, country, region_id
FROM customers
WHERE region_id IS NULL

Try WHERE region_id = NULL: every row disappears, Farid's too.

Next: COALESCE gives NULL a default · All lessons