Solution: Use Null as a Unique Value
Most problems with null values are based on a common misunderstanding of the behavior of SQLâs three-valued logic. For programmers accustomed to the conventional true/false logic implemented in most other languages, this can be a challenge. You can handle null values in SQL queries with a little study of how they work.
Null in Scalar Expressions
Suppose Stan is thirty years old, while Oliverâs age is unknown. If you ask whether Stan is older than Oliver, the only possible answer is âI donât know.â If you ask whether Stan is the same age as Oliver, the answer is also âI donât know.â If you ask what is the sum of Stanâs age and Oliverâs age, the answer is the same.
Charlieâs age is ...
Get SQL Antipatterns, Volume 1 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.