IS NULL
- SQL course
- Beginner
- Lesson 33/115
- 4 min
Test NULL values with IS NULL and IS NOT NULL.
IS NULL
With IS NULL you check whether a column is empty. = NULL does not work; always use IS NULL for NULL checks.
SELECT name FROM customers
WHERE email IS NULL;This query customers whose email is empty.
name is selected from customers. WHERE keeps only the rows where email IS NULL holds.
IS NULL — details
NULL means an unknown value; it is not a space or zero. Use IS NOT NULL to filter non-empty rows.
Practice IS NULL
Select names from customers where email is not null.
Starter code
-- not null
SELECT name
FROM customers
WHERESample solution
SELECT name
FROM customers
WHERE email IS NOT NULLExpected output
name Ayşe Alex
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is used to check NULL?
- IS NULL Correct answer
- == NULL
- NULL =
- = NULL
Explanation: IS NULL checks for NULL.
2 Not null
SELECT name FROM customers
WHERE email ____;
SELECT name FROM customers
WHERE email IS NOT NULL;
Explanation: IS NOT NULL is the right answer.
3 IS NULL: match the terms
| Term | Meaning |
|---|---|
IS NULL |
empty |
IS NOT NULL |
filled |
NULL |
unknown |
= |
equal |