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.
WHERE results: NOT EXISTS with NULL matching NULL
1 of 2 rows kept · WHERE keeps TRUE and drops FALSE or UNKNOWN.
| Row | Candidate | Predicate result | WHERE action | Why |
|---|---|---|---|---|
| 1 | NULL | FALSE | DROP | An equal value, including an explicit NULL-to-NULL match, exists in the exclusion list. |
| 2 | 10 | TRUE | KEEP | No value matches under the explicit NULL-to-NULL matching rule. |
Returned row IDs: 2
Compare all four policies
Changing the treatment of NULL changes the rule. These columns help you see that difference before choosing a rewrite.
| Row / value | IN | NOT IN | NOT EXISTS with ordinary equality | NOT IN with non-null guards | NOT EXISTS with NULL matching NULL |
|---|---|---|---|---|---|
| 1 / NULL | UNKNOWN | UNKNOWN | TRUE | FALSE | FALSE |
| 2 / 10 | UNKNOWN | UNKNOWN | TRUE | TRUE | TRUE |
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, NULL), (2, 10)
),
blocked (customer_id) AS (
VALUES (NULL)
)
SELECT c.row_id, c.customer_id
FROM candidates AS c
WHERE NOT EXISTS (SELECT 1 FROM blocked AS b WHERE b.customer_id = c.customer_id OR (b.customer_id IS NULL AND c.customer_id IS NULL))
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 →