NULL
A missing value. It is not zero and not an empty string, and it never equals anything, not even NULL.
Syntax
column IS NULL;column IS NOT NULL;
- COALESCE(column, fallback) replaces NULL with a value.
Example
SELECT first_name, COALESCE(loyalty_tier, 'none') AS tier FROM customers;
Every customer, with 'none' where there is no loyalty tier.
Tables used: customers. Try it in a lesson below.
Common mistakes
- NULL = NULL is not true. Use IS NULL.
- A NULL in an arithmetic expression gives NULL.