SQL TutorialLesson 11Free preview
SQL Null Values
This lesson is part of SQL · All levels
Summary
NULL means an unknown or unavailable value, not a zero or empty string. Any comparison with NULL, for example = NULL, always yields UNKNOWN so no row is selected. To check NULL use IS NULL and IS NOT NULL.
Key points
- NULL is an unknown value; it differs from 0, an empty string, or FALSE.
- Do not use = NULL or <> NULL; use IS NULL / IS NOT NULL.
- COUNT(column) ignores NULL, whereas COUNT(*) counts all rows.
- Arithmetic operations with NULL yield NULL, for example NULL + 5 = NULL.
- Column with constraint NOT NULL should not store NULL.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.