NULL: the value that is not a value
NULL means unknown or missing. It breaks tests that look simple. Learn how NULL behaves in comparisons, counts and constraints.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: an empty box on a form. A form has a box for a middle name. A blank box does not say zero. It does not say the name is empty. It may be unknown, skipped, or not used.
A clerk cannot say that two blank boxes hold the same name.
Daily List is a to-do list app. Tom, the tester, meets the same blank in a due date.
What it is: (a missing value) marks a fact that was not stored. (Structured Query Language) is the language used to ask a database a question. A table is a grid, a row is one item, and a column is one fact about that item. NULL is easy to mix up with zero and with empty text. The IS NULL test finds a missing value. A comparison with = does not.
Why it matters: written as due_date = NULL returns no rows even when dates are missing. Tom can then report that every task has a date. That report is false. A count or an average can also skip the blanks and still look tidy.
The blank-box picture stops at a second rule. NOT IN and NOT EXISTS look alike, but a missing value in the inner list makes NOT IN drop every row. NOT EXISTS does not.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Handling a blank box that means unknown, like a form with a skipped field.
- Value
- NULL
- Empty
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The blank box | NULL |
| Asking if it is blank | IS NULL |
| Skipping blanks in a count | COUNT of a column |
| Two blanks | Ordinary equality is UNKNOWN |
WHERE THIS PICTURE STOPS
- A form is read by people, but a database follows set rules.
- A blank may mean many things, but NULL is one marker.
- A clerk can ask, but a query cannot.
HOOK
Value, NULL, empty.
TELL A FRIEND
A blank box: unknown, skipped or none.
OFTEN MIXED UP WITH Looking at data with SQL SELECT. That topic reads one table. This one explains the value that breaks simple comparisons.
PRACTISE AND KEEP
Sources for this topic — 4 sources
- Market practice
Gotcha: SQL aggregate functions and NULL ↗ — SQLServerCentral · SQLServerCentral article: aggregate functions skip nulls, except COUNT(*), which counts rows (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
PostgreSQL documentation: 5.5 Constraints ↗ — PostgreSQL Global Development Group · PostgreSQL documentation: by default two null values are not considered equal in a unique constraint, and NULLS NOT DISTINCT, added in PostgreSQL 15, changes this (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Implementation-specific
PostgreSQL documentation ↗ — The PostgreSQL Global Development Group · PostgreSQL 18 official manual, opened 2026-11-06: functions-comparison §9.2, functions-subquery §9.24, functions-aggregate and ddl-constraints. Supports only PostgreSQL behavior; earlier execution evidence remains separately versioned.
An implementation, not the standard — which is the point. ISO/IEC 9075-2 is paywalled, and this documents the same constructs in text anybody can open. Its isolation-level chapter attributes to the standard explicitly, so it can carry a standard-level claim as long as the citation says which document it is quoting.
Cited as market practice rather than an official standard by kind: an engine's manual is authoritative about that engine and is not the obligation. Where a question turns on behaviour PostgreSQL chose rather than behaviour SQL requires, the answer has to say so.
One correction carried here because it circulates widely: the sentence "The fundamental difference between WHERE and HAVING…", quoted all over the internet as PostgreSQL documentation, is not in the current documentation. It was searched for in the source tree and is not there.
Read through a mirror, because the publisher's own domain could not be fetched (a reachability gap, not a statement about the publisher). A 403 there is a policy refusal and says nothing about whether the document exists or is reachable elsewhere.
Anyone on an unrestricted network should open the canonical URL above and confirm the section and page numbers cited against it. Every claim drawn from this entry is written so that it can be checked against a numbered page.
Read from the
postgres/postgresdocumentation source tree (doc/src/sgml), which the project itself maintains and which carries the section ids the published URLs are derived from — so a cited section id can be checked against the rendered page. - Implementation-specific
SQLite official documentation — constraints, types and transactions ↗ — SQLite · SQLite rolling official documentation, opened 2026-11-06: foreignkeys.html, datatype3.html, lang_createtable.html, lang_transaction.html, isolation.html, cli.html, series.html and lang_createtrigger.html as relevant. Historical SQLite 3.40.1 results remain distinct from in-memory audit witnesses on 3.53.1.
Relevant primary pages opened 6 November2026; rolling documentation and CLI examples (3.54.0) are distinct from historical lesson runs3.40.1 and audit witnesses3.53.1. No file/connected database audit execution.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.