Connecting expressions

and connects two expressions and returns results when both are true. or connects two or more conditions and returns results when either of the conditions is true.

When more than one logical operator is used in a statement, and is evaluated before or. You can change the order of execution with parentheses.

Table 4-6 shows the results of logical operations, including those that involve null values.

Table 4-6: Truth tables for logical expressions

and

TRUE

FALSE

NULL

TRUE

TRUE

FALSE

UNKNOWN

FALSE

FALSE

FALSE

FALSE

NULL

UNKNOWN

FALSE

UNKNOWN

or

TRUE

FALSE

NULL

TRUE

TRUE

TRUE

TRUE

FALSE

TRUE

FALSE

UNKNOWN

NULL

TRUE

UNKNOWN

UNKNOWN

not

TRUE

FALSE

FALSE

TRUE

NULL

UNKNOWN

The result UNKNOWN indicates that one or more of the expressions evaluates to NULL, and that the result of the operation cannot be determined to be either TRUE or FALSE. See “Using nulls in expressions” for more information.