Comparisons with null
- When we use single equal to compare anything with
NULL, we get anotherNULL. That’s even true when comparingNULLto itself. - SQL also has
IS NULLandIS NOT NULLcomparisons that properly check forNULLvalues.
SELECT 5 IS NOT NULL AS result;
--Result:
[{result: 1}]- Usually, you’ll see
IS NULLandIS NOT NULLas conditions inWHEREqueries.
SELECT * FROM users WHERE email IS NOT NULL