0% found this document useful (0 votes)
29 views1 page

Chapter 3: Selecting

The IS and IS NOT operators always return TRUE or FALSE and can be used to test boolean expressions and predicates. Examples show the results of using these operators on expressions evaluating to NULL, 0, or 1. The IS UNKNOWN operator is rarely used because for most purposes, UNKNOWN is treated the same as FALSE. The NOT, AND, and OR operators can change and combine intermediate TRUE, FALSE, and UNKNOWN results according to their truth tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

Chapter 3: Selecting

The IS and IS NOT operators always return TRUE or FALSE and can be used to test boolean expressions and predicates. Examples show the results of using these operators on expressions evaluating to NULL, 0, or 1. The IS UNKNOWN operator is rarely used because for most purposes, UNKNOWN is treated the same as FALSE. The NOT, AND, and OR operators can change and combine intermediate TRUE, FALSE, and UNKNOWN results according to their truth tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Chapter 3: Selecting 115

The IS and IS NOT operators can be used to test the result of a predicate or
boolean expression. These operators have the advantage that they always return
TRUE or FALSE, never UNKNOWN. Here are some examples showing the
results of IS and IS NOT operators:
X contains:
====================
Boolean Expression NULL 0 1
======================== ====== ===== =====
( X = 0 ) IS TRUE FALSE TRUE FALSE
( X = 0 ) IS FALSE FALSE FALSE TRUE
( X = 0 ) IS UNKNOWN TRUE FALSE FALSE
( X = 0 ) IS NOT TRUE TRUE FALSE TRUE
( X = 0 ) IS NOT FALSE TRUE TRUE FALSE
( X = 0 ) IS NOT UNKNOWN FALSE TRUE TRUE
The IS UNKNOWN operator is rarely used because for most purposes,
UNKNOWN is the same as FALSE. With a WHERE clause, for example, a row
yielding either UNKNOWN or FALSE will be eliminated.
The NOT, AND, and OR operators can be used to change and combine
intermediate TRUE, FALSE, and UNKNOWN results according to the follow-
ing truth tables. For example, if a <boolean_expression> results in TRUE,
then NOT <boolean_expression> is FALSE. Note that you cannot actually code
NOT TRUE in SQL Anywhere; the following tables are simply a shorthand
for explaining what happens when you code something like NOT X = 1:
NOT Result
=========== ======
NOT TRUE FALSE
NOT FALSE TRUE
NOT UNKNOWN UNKNOWN

AND Result
================== ======
TRUE AND TRUE TRUE
TRUE AND FALSE FALSE
TRUE AND UNKNOWN UNKNOWN
FALSE AND TRUE FALSE
FALSE AND FALSE FALSE
FALSE AND UNKNOWN FALSE
UNKNOWN AND TRUE UNKNOWN
UNKNOWN AND FALSE FALSE
UNKNOWN AND UNKNOWN UNKNOWN

OR Result
================== ======
TRUE OR TRUE TRUE
TRUE OR FALSE TRUE
TRUE OR UNKNOWN TRUE
FALSE OR TRUE TRUE
FALSE OR FALSE FALSE
FALSE OR UNKNOWN UNKNOWN
UNKNOWN OR TRUE TRUE
UNKNOWN OR FALSE UNKNOWN
UNKNOWN OR UNKNOWN UNKNOWN

You might also like