PREP WITH PROOF
Menu
FREE LEARNING TOOL · NO SIGNUP

SQL NULL explorer

Change the values. Compare the predicates. See exactly which rows WHERE keeps.

Choose your inputs

Enter up to 20 integers per list, from -1000000 to 1000000. Use NULL for a missing value. Leave the exclusion list empty to test an empty subquery. Duplicate candidates remain separate rows.

Comma-separated integers or NULL. This tool models scalar integer comparisons; it does not run arbitrary SQL.

Reset example

WHERE results: NOT IN

0 of 3 rows kept · WHERE keeps TRUE and drops FALSE or UNKNOWN.

RowCandidatePredicate resultWHERE actionWhy
110UNKNOWNDROPNo equal known key was found, but the exclusion list contains NULL. WHERE drops UNKNOWN.
220FALSEDROPAn equal known exclusion key exists.
3NULLUNKNOWNDROPOrdinary comparisons cannot establish equality or inequality for this NULL key. WHERE drops UNKNOWN.

Returned row IDs: None

Compare all four policies

Changing the treatment of NULL changes the rule. These columns help you see that difference before choosing a rewrite.

Row / valueINNOT INNOT EXISTS with ordinary equalityNOT IN with non-null guardsNOT EXISTS with NULL matching NULL
1 / 10UNKNOWNUNKNOWNTRUETRUETRUE
2 / 20TRUEFALSEFALSEFALSEFALSE
3 / NULLUNKNOWNUNKNOWNTRUEFALSEFALSE

Run the same case in your database

Select and copy this read-only query. It creates its input rows in CTEs and does not modify tables. Verify syntax and behavior on your database engine.

WITH candidates (row_id, customer_id) AS (
  VALUES (1, 10), (2, 20), (3, NULL)
),
blocked (customer_id) AS (
  VALUES (20), (NULL)
)
SELECT c.row_id, c.customer_id
FROM candidates AS c
WHERE c.customer_id NOT IN (SELECT b.customer_id FROM blocked AS b)
ORDER BY c.row_id;

How to interpret the result

NULL represents a missing or unknown value. Ordinary equality cannot establish that NULL equals NULL. For a nonempty right-hand set, NOT IN can be UNKNOWN when no equal known value exists but a comparison involves NULL. An empty subquery is a separate case: scalar NOT IN is TRUE.

NOT EXISTS with ordinary equality can keep a candidate whose key is NULL. The guarded policy rejects missing candidate keys explicitly. The NULL-matching policy intentionally treats two missing keys as a match. Decide which rule your application needs before switching syntax.

This is a focused learning model for scalar integers and NULL, not a general SQL engine. It does not model text collation, type coercion, composite keys, performance, or every database dialect. Inputs appear in the page URL when you submit; use learning values rather than real customer identifiers.

Read the full NOT IN and NULL troubleshooting guide →

Explore duplicate matches and unmatched rows in SQL JOIN →

Official references