Null values do not always provide a result that is null, in a logical expression the result might be a non-Null.
In general, when any operand of an expression is Null, then the answer is Null. (Use the syntax IS NULL and IS NOT NULL to test whether an expression is Null or not Null.)
However, when a Null is an operand in a logical expression, the result still might be non-Null. The following table shows how logical operators AND, OR, XOR, and NOT behave with TRUE, FALSE, and Null operands:
|
x |
y |
x AND y |
x OR y |
NOT x |
x XOR y |
|---|---|---|---|---|---|
|
TRUE |
TRUE |
TRUE |
TRUE |
FALSE |
FALSE |
|
TRUE |
FALSE |
FALSE |
TRUE |
FALSE |
TRUE |
|
TRUE |
NULL |
NULL |
TRUE |
FALSE |
NULL |
|
FALSE |
TRUE |
FALSE |
TRUE |
TRUE |
TRUE |
|
FALSE |
FALSE |
FALSE |
FALSE |
TRUE |
FALSE |
|
FALSE |
NULL |
FALSE |
NULL |
TRUE |
NULL |
|
NULL |
TRUE |
NULL |
TRUE |
NULL |
NULL |
|
NULL |
FALSE |
FALSE |
NULL |
NULL |
NULL |
|
NULL |
NULL |
NULL |
NULL |
NULL |
NULL |
The reason for this is that in some cases a subset of the expression is sufficient to determine the truth or falsehood of the expression. For example, when evaluating X AND Y, if the server sees that X is false, then the server knows that X AND Y cannot be true, so the server simply knows that it can returns FALSE regardless of the value of Y. Similarly, if the expression is X OR Y, and X is true, then the server returns TRUE regardless of the value of Y.