MySQL + SQL · Lesson 49
IS NULL and IS NOT NULL
What is NULL?
NULL means "no value" — empty/unknown. It is NOT the same as 0 or an empty string. You cannot test it with
=; use IS NULL.Examples
-- find students with no phone number
SELECT * FROM students WHERE phone IS NULL;
-- find students who have a phone number
SELECT * FROM students WHERE phone IS NOT NULL;
Common Trap
WHERE phone = NULL does NOT work and returns nothing. Always use IS NULL / IS NOT NULL.Summary
- NULL = unknown/missing, not 0 or empty.
- Test with
IS NULL/IS NOT NULL, never= NULL.