Part 20: Handling NULL Values: IS NULL & Three-Valued Logic
NULL in SQL represents the absence of data or an unknown value—it does NOT equal zero 0, false, or an empty string ''.
1. Three-Valued Logic (3VL)
SQL boolean expressions evaluate to one of three states:
- TRUE
- FALSE
- UNKNOWN (Result of any comparison with NULL)
-- ❌ NEVER DO THIS: Returns UNKNOWN (0 rows returned)
SELECT * FROM users WHERE phone = NULL;
-- CORRECT:
SELECT * FROM users WHERE phone IS NULL;
SELECT * FROM users WHERE phone IS NOT NULL;
Key Takeaways
NULLis not a value; it is a marker of unknown state.- Always use
IS NULLandIS NOT NULLfor comparisons.
In Part 21, we enter Module 3 to master Sorting Results with ORDER BY!

