Skip to content
Quantoros

What is NULL in SQL?

SQLLevel: FoundationNULL Basics

What is NULL in SQL?

Hints
  • Distinguish a missing value from zero, an empty string and false.
  • Test comparison, aggregation and filtering on a tiny missing-value example.

Answer

NULL represents the absence of a value — unknown or not applicable. It is not zero, not an empty string, not false. It's a special state.

Critical behavior: NULL is not equal to anything, including itself.

SELECT NULL = NULL;    -- Returns NULL, not TRUE
SELECT NULL != NULL;   -- Returns NULL, not FALSE
SELECT NULL IS NULL;   -- Returns TRUE (correct way to check)

This is "three-valued logic" — conditions can be TRUE, FALSE, or NULL (unknown).

Source and licence: SQL Interview Questions — Arda Kocadoru · MIT

Related questions