0Pricing
SQL Academy · Lesson

What NULL Really Means

Unknown, not zero and not empty.

Meet NULL

NULL is SQL's way of saying "I don't know". It is not zero, not an empty string, and not false — it represents the absence of a value.

Whenever a column has no known value, the database stores NULL there. Learning how NULL behaves is one of the most important steps to writing correct queries.

-- A customers table where some phone numbers are unknown
SELECT id, name, phone
FROM customers;

-- id | name    | phone
-- ---+---------+------------
--  1 | Alice   | 555-0101
--  2 | Bob     | NULL        <- phone unknown
--  3 | Carol   | NULL

NULL Is Not Zero

A common mistake is treating NULL like the number 0. They are completely different.

  • 0 is a known value: zero.
  • NULL means the value is missing or unknown.

If an account balance is 0, the customer has no money. If it is NULL, we simply don't know the balance yet.

SELECT id, balance
FROM accounts;

-- id | balance
-- ---+--------
--  1 | 0        <- known: empty wallet
--  2 | NULL     <- unknown: not recorded yet

All lessons in this course

  1. What NULL Really Means
  2. IS NULL and IS NOT NULL
  3. COALESCE and NULLIF
  4. NULLs in Aggregates and Joins
← Back to SQL Academy