three_value_logicIn SQL, When a NULL is involved in a comparison operation, the result is considered to be UNKNOWN (it may be TRUE or it may be FALSE). Hence, SQL uses a three valued logic with values TRUE, FALSE, and UNKNOWN instead of the standard two-valued (Boolean) logic with values TRUE or FALSE. It is therefore necessary to define the results (or truth values) of three-valued logical expressions when the logical connectives AND, OR, and NOT are used.

[table caption=”Three-Valued logic with AND” width=”350″ colwidth=”100|50|50″ colalign=”left|left|left|left”]
AND,TRUE,FALSE,UNKNOWN,
TURE, T, F, UNK
FALSE, F,F,F
UNKOWN,UNK,F,UNK
[/table]

[table caption=”Three-Valued logic with OR ” width=”350″ colwidth=”100|50|50″ colalign=”left|left|left|left”]
OR ,TRUE,FALSE,UNKNOWN,
TURE, T, T,T
FALSE, T,F,UNK
UNKOWN,T,UNK,UNK
[/table]

[table caption=”Three-Valued logic with NOT” width=”150″ colwidth=”100|50|50″ colalign=”left|left”]
NOT ,
TURE, F
FALSE, T
UNKOWN,UNK
[/table]

Reference:

Elmasri, R., & Navathe, S. (2011). Fundamentals of database systems. Boston: Addison-Wesley.