Skip to main content

IS NULL

Operators and expressions

Tests whether a value is NULL. Comparisons with NULL are unknown (x = NULL is never true), so IS NULL is the only reliable test.

Syntax​

SELECT ...
FROM <source> [ <alias> ]
WHERE <expression> IS [ NOT ] NULL
OR <expression> IS [ NOT ] { TRUE | FALSE }
...

Parameters​

ParameterDescription
IS NULLTrue when the value is NULL. Never NULL itself.
IS NOT NULLTrue when the value is present.
IS TRUE, IS FALSETrue when a boolean is true, or false. A NULL gives false.
IS NOT TRUE, IS NOT FALSEThe opposite: true for NULL as well.

Usage notes​

  • In a text, date or timestamp column, an empty string is NULL. IS NULL matches both a missing value and ''. A numeric 0 and a boolean false are values, not NULL.
  • An expression that produces empty text, such as trim(' '), also reads as NULL.
  • IS NULL works anywhere an expression does: SELECT o.closed_at IS NULL AS still_open.
  • A plain column IS [NOT] NULL is pushed into the read of the table.
  • To replace NULLs with a value, use COALESCE. To turn a value into NULL, use NULLIF.

Examples​

Orders not yet closed:

SELECT o.key, o.placed_at FROM Order o WHERE o.closed_at IS NULL
keyplaced_at
PO-10012026-09-14 10:02:00
PO-10172026-10-02 08:45:00

Keep NULLs that a comparison would drop:

SELECT o.key, o.status FROM Order o WHERE o.status <> 'closed' OR o.status IS NULL

A boolean test and a flag column:

SELECT o.key, o.closed_at IS NOT NULL AS is_closed FROM Order o WHERE o.is_priority IS TRUE

Not supported​

RefusedWrite instead
a IS DISTINCT FROM b, a IS NOT DISTINCT FROM b(a = b OR (a IS NULL AND b IS NULL)), or its negation
ISNULL(x), x ISNULL, x NOTNULLx IS NULL, x IS NOT NULL
IS UNKNOWNIS NULL
-- Refused by the engine
SELECT o.key FROM Order o WHERE o.status IS DISTINCT FROM o.previous_status
-- Refused by the engine
SELECT o.key FROM Order o WHERE isnull(o.closed_at)
-- Refused by the engine
SELECT o.key FROM Order o WHERE o.closed_at IS UNKNOWN

See also​

COALESCE · NULLIF · Operators · IN · WHERE