MEPX
Chapter 3 of 10All chapters

Chapter 3 of 10

NULL

Unknown, not empty.

Why it is different

NULL means the value is unknown. Comparing anything with NULL gives unknown rather than true, so column = NULL never matches, even for rows that are NULL.

  • Use IS NULL and IS NOT NULL instead.
  • COALESCE(column, fallback) substitutes a value when one is missing.

Where it bites

Aggregates skip NULLs, so AVG ignores them rather than treating them as zero. A NOT IN list containing a NULL returns nothing at all, which is the classic silent bug.