9.1. Logical Operators #

The usual logical operators are available:

boolean AND boolean → boolean
boolean OR boolean → boolean
NOT boolean → boolean

SQL uses a three-valued logic system with true, false, and null, which represents “unknown”. In the truth tables below, the left operand of a binary operator selects the row, and the right operand the column:

ANDTRUEFALSENULL
TRUETRUEFALSENULL
FALSEFALSEFALSEFALSE
NULLNULLFALSENULL

ORTRUEFALSENULL
TRUETRUETRUETRUE
FALSETRUEFALSENULL
NULLTRUENULLNULL

NOTTRUEFALSENULL
 FALSETRUENULL

The operators AND and OR are commutative, that is, you can switch the left and right operands without affecting the result. (However, it is not guaranteed that the left operand is evaluated before the right operand. See Section 4.2.14 for more information about the order of evaluation of subexpressions.)