NULL: the value that is not a value
Step 1 of 110%
Concept · step 1 of 11
What NULL is
NULL means unknown or missing. It is not zero and not an empty string: it is the absence of a value, and SQL reasons about it with three truth values instead of two.
- Comparisons give unknown.
7 = NULLis not false, it is NULL, and so isNULL = NULL. - WHERE keeps only true. a row whose condition is unknown is left out, exactly like one that is false.
- Ask with IS.
phone IS NULLis true or false, never unknown.
SELECT name FROM customers WHERE phone IS NULL;Linus has no phone on the board. NULL also spreads:
PostgreSQL docs: Comparison operators and IS DISTINCT FROM ↗'tel: ' || phone is NULL when the phone is, and so is most arithmetic. Every step in this lesson is a place where that one NULL changes the answer, and where it surprises people who have written SQL for years.Starting Postgres in your browser
About 5 MB the first time, cached after that.
PostgreSQL running in your browser