What is NULL?
NULL represents missing or unknown data. It's NOT the same as:
- Zero (0)
- Empty string ('')
- False
NULL Behavior
sql
1-- These don't work with NULL:
2NULL = NULL -- Returns NULL, not true!
3NULL != NULL -- Returns NULL, not true!Why NULL is Special
NULL means "unknown value". You can't compare unknowns.
Checking for NULL
Use IS NULL or IS NOT NULL:
sql
1-- Correct way
2SELECT * FROM students WHERE phone IS NULL;
3
4-- Wrong way (won't work!)
5SELECT * FROM students WHERE phone = NULL;