You run SELECT * FROM users WHERE email = NULL expecting to retrieve all users without an email address. The query returns zero rows despite NULL values existing in the table. Why?
ANULL is stored as an empty string, so you need WHERE email = '' instead
BNothing equals NULL — not even NULL itself — so = NULL never evaluates to true; you must use IS NULL
CThe = operator does not work on string columns; use LIKE instead
DNULL values are filtered out before the WHERE clause is evaluated
In SQL's three-valued logic, any comparison involving NULL yields NULL (not true, not false). This means email = NULL evaluates to NULL for every row — including rows where email actually is NULL — so no rows pass the filter. IS NULL is the only correct test for missing values: it is explicitly designed to check for the absence of a value, not to compare values.
Question 2 Multiple Choice
Given the condition WHERE a = 1 OR b = 2 AND c = 3, which rows does SQL return?
ARows where (a = 1 OR b = 2) AND c = 3
BRows where a = 1, OR rows where both b = 2 AND c = 3
CRows where all three conditions are true simultaneously
DRows where any one of a = 1, b = 2, or c = 3 is true
AND binds tighter than OR — the same precedence rule as multiplication over addition in arithmetic. So this parses as a = 1 OR (b = 2 AND c = 3). A row is returned if a = 1 regardless of b and c, OR if both b = 2 and c = 3 regardless of a. This precedence rule is a common source of subtle bugs; using explicit parentheses makes your intent clear and prevents misreads.
Question 3 True / False
WHERE price BETWEEN 10 AND 50 includes rows where price equals exactly 10 or exactly 50.
TTrue
FFalse
Answer: True
BETWEEN is inclusive on both endpoints. It is equivalent to WHERE price >= 10 AND price <= 50. This is worth memorizing because it is easy to assume BETWEEN is exclusive. When you need to exclude an endpoint, use explicit comparison operators instead.
Question 4 True / False
WHERE status = NULL is equivalent to WHERE status IS NULL and both will correctly return rows where status has no value.
TTrue
FFalse
Answer: False
WHERE status = NULL never returns any rows because = NULL always evaluates to NULL (unknown), not true. IS NULL is the only correct way to test for missing values in SQL. These two expressions look similar but behave completely differently, making NULL handling one of the most common sources of SQL bugs for new practitioners.
Question 5 Short Answer
Why does WHERE column = NULL never return any rows, even when NULL values exist in that column?
Think about your answer, then reveal below.
Model answer: SQL uses three-valued logic: expressions evaluate to true, false, or NULL. Any comparison with NULL — including NULL = NULL — evaluates to NULL, not true. The WHERE clause only keeps rows where the condition is true; a NULL result is treated the same as false and the row is discarded. Since email = NULL evaluates to NULL for every row (including those where email is NULL), no rows pass the filter. IS NULL is a special predicate that tests for the absence of a value rather than comparing it.
This is one of the most important SQL behaviors to internalize. NULL means 'unknown' — you can't know if an unknown value equals another value, including another unknown. The practical rule: always use IS NULL or IS NOT NULL when testing for missing data, never = NULL or != NULL.