beginnerSQL Fundamentals Deep Dive — Data Types, NULL Handling & Query Execution Order

Why does WHERE column = NULL never match any rows, even when the column genuinely contains NULLs?

NULL represents 'unknown,' not a comparable value — NULL = NULL evaluates to NULL (unknown), not TRUE, because SQL uses three-valued logic (TRUE/FALSE/UNKNOWN) and only rows evaluating to exactly TRUE are kept. The correct form is WHERE column IS NULL, which checks for the unknown state directly rather than comparing against it.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why should monetary values always be stored as NUMERIC rather than REAL or FLOAT?← Back to all SQL questions