Oracle9i SQL Reference Release 2 (9.2) Part Number A96540-02 |
|
|
View PDF |
A logical condition combines the results of two component conditions to produce a single result based on them or to invert the result of a single condition. Table 5-3 lists logical conditions.
Table 5-4 shows the result of applying the NOT
condition to an expression.
-- | TRUE | FALSE | UNKNOWN |
---|---|---|---|
NOT |
|
|
|
Table 5-5 shows the results of combining the AND
condition to two expressions.
AND | TRUE | FALSE | UNKNOWN |
---|---|---|---|
TRUE |
|
|
|
FALSE |
|
|
|
UNKNOWN |
|
|
|
For example, in the WHERE
clause of the following SELECT
statement, the AND
logical condition is used to ensure that only those hired before 1984 and earning more than $1000 a month are returned:
SELECT * FROM employees WHERE hire_date < TO_DATE('01-JAN-1989', 'DD-MON-YYYY') AND salary > 2500;
Table 5-6 shows the results of applying OR
to two expressions.
OR | TRUE | FALSE | UNKNOWN |
---|---|---|---|
TRUE |
|
|
|
FALSE |
|
|
|
UNKNOWN |
|
|
|
For example, the following query returns employees who have a 40% commission rate or a salary greater than $20,000:
SELECT employee_id FROM employees WHERE commission_pct = .4 OR salary > 20000;