How does SQL treat NULL in comparisons?medium

Type
conceptual
Topic
null-comparisons
Frequency
common
Tags
null, three-valued-logic, filters
Answer

NULL represents unknown, so comparisons like = NULL do not evaluate to true.

Explanation

Use IS NULL or IS NOT NULL. NULL also affects joins, filters, aggregates, and three-valued logic, so explicit handling prevents subtle bugs.

Follow-upHow do COUNT(*) and COUNT(column) handle NULL differently?