NULL is not a value but a special marker that signifies missing, undefined, or inapplicable data. Whenever a column contains NULL, mathematical and string operations return NULL, and comparison operators ( =, <, > ) evaluate to UNKNOWN instead of TRUE or FALSE. This behavior introduces three-valued logic (TRUE, FALSE, UNKNOWN) in SQL. NULL can be inserted explicitly or implicitly when a column allows it and no value is provided. To test for NULL you must use the predicates IS NULL or IS NOT NULL; equality operators do not work. Functions like COALESCE, NVL, IFNULL, and NULLIF help convert or handle NULL for safer calculations. Aggregate functions ignore NULL except COUNT(*). Constraints such as PRIMARY KEY and NOT NULL prevent NULL storage. Indexes may treat NULL rows differently across vendors, so query plans can vary. Understanding how NULL interacts with joins, GROUP BY, and ORDER BY is critical to avoid incorrect results.
IS NULL, IS NOT NULL, COALESCE, NULLIF, NVL, IFNULL, THREE-VALUED LOGIC, NOT NULL constraint
SQL-92 standard
SQL considers NULL unknown, so comparisons with = or <> resolve to UNKNOWN, which fails filtering. Always use IS NULL or IS NOT NULL.
All aggregates except COUNT(*) ignore NULL. Use COUNT(*) to include every row or COALESCE to convert NULL before aggregating.
No. Zero and empty strings are actual values. NULL signifies the absence of any value and does not compare equal to anything, including itself.
Wrap columns in COALESCE(column, fallback) or vendor-specific functions like IFNULL (MySQL) or NVL (Oracle) to output a substitute when the column is NULL.