Short, interview-ready answer
NULLmeans “unknown or not applicable”, while0, empty string (''), andFALSEare known, concrete values.NULLpropagates through expressions and comparisons, whereas the others behave like normal values.
Core semantic difference
NULL
- Represents absence of a value
- Not equal to anything — not even another
NULL - Causes expressions to evaluate to
UNKNOWN
0
- A numeric value
- Fully comparable and calculable
'' (empty string)
- A string of length 0
- Still a valid value
FALSE
- A boolean value
- Known and comparable
Comparison behavior (this is the trap)
NULL = NULL → UNKNOWN
NULL <> NULL → UNKNOWN
NULL = 0 → UNKNOWN
NULL = '' → UNKNOWN
but
0 = 0 → TRUE
'' = '' → TRUE
FALSE = FALSE → TRUE
Consequence
WHERE column = NULL
Correct
WHERE column IS NULL
Logical expressions (three-valued logic)
TRUE AND NULL → UNKNOWN
FALSE AND NULL → FALSE
TRUE OR NULL → TRUE
FALSE OR NULL → UNKNOWN
NOT NULL → UNKNOWN
WHERE keeps only TRUE, so UNKNOWN rows are filtered out.
Aggregations and NULLs
COUNT(column) -- ignores NULL
COUNT(*) -- counts rows
SUM(column) -- ignores NULL
But:
AVG(NULL) → NULL
This surprises many candidates.
NULL in constraints
UNIQUEallows multiple NULLs (in most DBs)NOT NULLenforces presenceCHECK (col > 0)→ fails ifcolis NULL (because result is UNKNOWN)
Why confusing NULL with 0/”/FALSE is dangerous
Bad design example
balance INT DEFAULT 0
Does 0 mean:
- truly zero?
- unknown?
- not loaded yet?
Correct modeling:
- Use
NULLfor “unknown” - Use real values for real meaning
Interview-ready final answer (clean)
“
NULLrepresents the absence of a value, not a value itself, while0, empty string, andFALSEare concrete values.
Comparisons withNULLevaluate toUNKNOWNdue to SQL’s three-valued logic, which is whyIS NULLmust be used instead of=.
MisusingNULLleads to subtle filtering and aggregation bugs.”
Senior red flags 🚩
If a candidate says:
- “NULL is just another value”
- “NULL equals NULL”
- “I use 0 instead of NULL”