NULL
SQL's marker for a missing or unknown value, which is not zero, not empty text and not equal to anything, even another NULL.
In more detail
Any comparison with NULL, including NULL = NULL, gives unknown rather than true, so a filter written with = NULL keeps no rows. Test for it with IS NULL. Most aggregates skip NULLs, and an outer join produces NULLs for the columns of rows that had no match.
Related terms
- IS NULL — The test for whether a value is NULL, which works where = NULL never does.
- three-valued logic — SQL's rule that a condition can be true, false or unknown, where unknown comes from comparing with NULL.
- NOT NULL — A constraint that a column must always hold a value, so NULL is rejected.
- LEFT JOIN — A join that keeps every row of the left table and adds the matching right-hand rows, or NULLs when there is no match.
Taught in
- Forty Terabytes Nobody Opens: Storage And Databases — CompTIA Cloud+ (CV0-004) Exam Prep
- Data Types And What To Choose — PostgreSQL, Indexing & Relational Data Modeling
- Filtering With The WHERE Clause — PostgreSQL, Indexing & Relational Data Modeling
- Aggregate Functions — PostgreSQL, Indexing & Relational Data Modeling