Datasheet
34
Chapter 1
Introducing SQL
OR
The OR operator evaluates to TRUE if either operand is TRUE. It evaluates to FALSE if both
operands are
FALSE. Otherwise, it returns NULL.
SELECT first_name, last_name
FROM employees
WHERE first_name = ‘Kelly’
OR last_name = ‘Smith’;
FIRST_NAME LAST_NAME
-------------------- -------------------------
Lindsey Smith
William Smith
Kelly Chung
Logical Operator Truth Tables
The following tables are the truth tables for the three logical operators.
Table 1.7 is a truth table for the
AND operator.
TABLE 1.7 AND Truth Table
AND TRUE FALSE UNKNOWN
TRUE TRUE FALSE UNKNOWN
FALSE FALSE FALSE FALSE
UNKNOWN UNKNOWN FALSE UNKNOWN
Table 1.8 is the truth table for the OR operator.
TABLE 1.8 OR Truth Table
OR TRUE FALSE UNKNOWN
TRUE TRUE TRUE TRUE
FALSE TRUE FALSE UNKNOWN
UNKNOWN TRUE UNKNOWN UNKNOWN
95127c01.indd 34 2/18/09 6:37:10 AM