Home / SQL / Reference / Filtering

SQL IS NULL

Test for a missing (NULL) value.

Syntax

WHERE col IS NULL
WHERE col IS NOT NULL

NULL means unknown, and any comparison with it (even = NULL) is unknown, never true. IS NULL is the only test that works.

Example

Query (on the shop database used in the SQL course)

SELECT name, city
FROM customers
WHERE city IS NULL;

Result

namecity
Olivia SmithNULL
Hiroshi TanakaNULL

2 rows

Related

Learn it step by step in the free lesson WHERE: Filtering Rows, with exercises that check your queries.