What was the rationale behind designing a NULL boolean expression
NULL
means you don't know what the value is. Perhaps this may not be true. We don't know yet.
NULL OR False
it's easier here. This expression clearly cannot evaluate to True
at this point. On the other hand, it is not certain False
. We still don't have enough information to solve the whole expression, so this NULL
is the only result that makes sense.
NULL OR TRUE
on the other hand, provides sufficient information to resolve the entire expression. Provided OR
both sides are true, then the logically complete result is true; it doesn't matter what the other side does. Even if this one NULL
ended up being False
, the result of the expression still evaluates to True
. With NULL
nothing you can do to make this expression False
.
And, just for the sake of clarity, it's also worth looking at NULL AND TRUE
and NULL AND FALSE
. The former will also evaluate as NULL
, because, again, we don't have enough information to fully solve the expression, while the latter will evaluate as False
, since no matter how the NULL
expression works, the expression can't become True
.
If you really want to get confused, think about what happens when you compare equality NULL = NULL
. The real result is that we don't know (NULL) yet, but if you force the problem, the database will evaluate the expression as False: NULL is not equal to itself.
source to share