Using nulls in expressions  Difference between FALSE and UNKNOWN

Chapter 4: Expressions, Identifiers, and Wildcard Characters

Comparisons that return TRUE

In general, the result of comparing null values is UNKNOWN, since it is not possible to determine whether NULL is equal (or not equal) to a given value or to another NULL. However, the following cases return TRUE when expression is any column, variable or literal, or combination of these, which evaluates as NULL:

The negative versions of these expressions return TRUE when the expression does not evaluate to NULL:

NoteThe far right side of these exceptions is a literal null, or a variable or parameter containing NULL. If the far right side of the comparison is an expression (such as @nullvar + 1), the entire expression evaluates to NULL.

Following these rules, null column values do not join with other null column values. Comparing null column values to other null column values in a where clause always returns UNKNOWN for null values, regardless of the comparison operator, and the rows are not included in the results. For example, this query returns no result rows where column1 contains NULL in both tables (although it may return other rows):

select column1 
from table1, table2 
where table1.column1 = table2.column1




Copyright © 2005. Sybase Inc. All rights reserved. Difference between FALSE and UNKNOWN

View this book as PDF