0
0
SQLquery~10 mins

IS NULL vs equals NULL in SQL - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Concept Flow - IS NULL vs equals NULL
Start Query
Check Condition
Return True
Filter Rows
Result Set
The query checks each row's column with IS NULL or = NULL. IS NULL returns true for NULLs, = NULL returns unknown, so no rows match.
Execution Sample
SQL
SELECT * FROM users WHERE email IS NULL;
SELECT * FROM users WHERE email = NULL;
Two queries: one finds rows where email is NULL, the other tries to find rows where email equals NULL but returns no rows.
Execution Table
StepRow email valueConditionEvaluationRow Included in Result?
1NULLemail IS NULLTRUEYes
2NULLemail = NULLUNKNOWN (treated as FALSE)No
3'user@example.com'email IS NULLFALSENo
4'user@example.com'email = NULLUNKNOWN (treated as FALSE)No
5'' (empty string)email IS NULLFALSENo
6'' (empty string)email = NULLUNKNOWN (treated as FALSE)No
💡 All rows checked; only rows with email IS NULL condition TRUE are included.
Variable Tracker
VariableStartAfter Row 1After Row 2After Row 3After Row 4After Row 5After Row 6
emailN/ANULLNULL'user@example.com''user@example.com'''''
email IS NULLN/ATRUETRUEFALSEFALSEFALSEFALSE
email = NULLN/AUNKNOWNUNKNOWNUNKNOWNUNKNOWNUNKNOWNUNKNOWN
Key Moments - 2 Insights
Why does 'email = NULL' never return any rows even if some emails are NULL?
Because in SQL, comparing anything to NULL with '=' results in UNKNOWN, which is treated as FALSE in WHERE filters. See execution_table rows 2,4,6.
What does 'IS NULL' check differently than '='?
'IS NULL' explicitly checks if a value is NULL and returns TRUE for NULLs, allowing those rows to be included. See execution_table rows 1 and 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the evaluation of 'email = NULL' when email is NULL?
ATRUE
BFALSE
CUNKNOWN
DNULL
💡 Hint
Check row 2 in the execution_table under 'Evaluation' for 'email = NULL' with email NULL.
At which step does 'email IS NULL' return TRUE?
AStep 1
BStep 3
CStep 5
DStep 6
💡 Hint
Look at execution_table rows where 'email IS NULL' is TRUE.
If we replace 'email = NULL' with 'email IS NULL', how would the result change?
ANo rows would be returned
BOnly rows with NULL emails would be returned
CAll rows would be returned
DOnly rows with empty string emails would be returned
💡 Hint
Refer to the difference in evaluation between 'email = NULL' and 'email IS NULL' in the execution_table.
Concept Snapshot
IS NULL checks if a value is NULL and returns TRUE for NULLs.
Using '=' to compare with NULL returns UNKNOWN, treated as FALSE.
Use IS NULL to find NULL values in SQL queries.
Example: WHERE column IS NULL returns rows with NULLs.
WHERE column = NULL returns no rows.
Always use IS NULL for NULL checks.
Full Transcript
This visual execution shows how SQL treats NULL comparisons. When checking if a column is NULL, use IS NULL because it returns TRUE for NULL values. Using '=' to compare with NULL returns UNKNOWN, which SQL treats as FALSE, so no rows match. The execution table shows rows with NULL emails pass the IS NULL check but fail the '=' check. This is why IS NULL is the correct way to find NULLs in SQL.