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.
💻 Live Code Editor
This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.