Basics · Lesson 13 of 19

NULL Values and IS NULL

NULL means unknown or missing data - it's not zero, not empty string, it's the absence of a value.

You cannot use = to check for NULL. This won't work: WHERE email = NULL -- WRONG!

Instead, use IS NULL or IS NOT NULL:

SELECT * FROM employees WHERE manager_id IS NULL;

This finds employees with no manager: the people at the top of the company.

IS NOT NULL finds rows that DO have a value:

SELECT * FROM employees WHERE email IS NOT NULL;

Remember: NULL = NULL is not true in SQL!

Check your understanding

Find employees who have no manager.

Examples run on the employees sample database. Open any of them in the playground to experiment.