Skip to main content

Logical Operators

The usual logical operators are available for boolean values: AND, OR, NOT. SQL uses a three-valued logic system with true, false, and null, which represents "unknown". Observe the following truth tables:

aba AND ba OR b
TRUETRUETRUETRUE
TRUEFALSEFALSETRUE
TRUENULLNULLTRUE
FALSEFALSEFALSEFALSE
FALSENULLFALSENULL
NULLNULLNULLNULL
aNOT a
TRUEFALSE
FALSETRUE
NULLNULL

The operators AND and OR are commutative, that is, you can switch the left and right operand without affecting the result.