any, all, and in  Transact-SQL extensions

Chapter 1: SQL Building Blocks

and and or

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. Use parentheses to change the order of execution.

Table 1-7 shows the results of logical operations, including those that involve null values:

Table 1-7: 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.





Copyright © 2005. Sybase Inc. All rights reserved. Transact-SQL extensions

View this book as PDF