three-valued logic
SQL's rule that a condition can be true, false or unknown, where unknown comes from comparing with NULL.
In more detail
WHERE keeps a row only when its condition is true, so unknown behaves like false in a filter. NOT unknown is still unknown, which is why NOT IN with a NULL in its list returns nothing. CHECK constraints, by contrast, accept a row unless the condition is false.
Related terms
- 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.
- IS NULL — The test for whether a value is NULL, which works where = NULL never does.
- IN — An operator that is true when a value equals any value in a list or in the rows a subquery returns.
- logical operator — An operator such as AND, OR or NOT that combines or reverses true-or-false conditions.
Taught in
- Filtering With The WHERE Clause — PostgreSQL, Indexing & Relational Data Modeling