Logical conditions combine two conditions into a single result or reverse the result of a single condition.
The logical conditions include NOT, AND, and OR.
Logical condition NOT
The logical condition NOT represents 'not' and can reverse the result of a single condition.
Evaluation rules
If the condition is FALSE, it returns TRUE. If the condition is TRUE, it returns FALSE. If it is UNKNOWN, it returns UNKNOWN.
Logical condition NOT example
SELECT * FROM emp WHERE NOT (job_id IS NULL) ORDER BY empno;
SELECT * FROM emp WHERE NOT (salary BETWEEN 11000 AND 22000) ORDER BY empno;
Logical condition AND
The logical condition AND represents 'and' and is used to connect two conditions.
Evaluation rules
If both conditions are TRUE, it returns TRUE. If either is FALSE, it returns FALSE. If one condition is UNKNOWN and the other is FALSE, it returns FALSE. Otherwise, it returns UNKNOWN.
Logical condition AND example
SELECT * FROM emp WHERE job_id = 'PU_CLERK' AND dept_id = 32 ORDER BY empno;
Logical condition OR
The logical condition OR represents 'or' and means either one can be used.
Evaluation rules
If either condition is TRUE, it returns TRUE. If both are FALSE, it returns FALSE. Otherwise, it returns UNKNOWN.
Logical condition OR example
SELECT * FROM emp WHERE job_id = 'PU_CLERK' OR dept_id = 10 ORDER BY empno;
