Logical conditions combine two conditions to generate a single result or invert the result of a single condition.
Logical NOT condition
The logical NOT condition indicates "not" and can invert the result of a single condition. If the condition is FALSE, TRUE is returned. If the condition is TRUE, FALSE is returned. If the condition is UNKNOWN, UNKNOWN is returned.
Examples of the logical NOT condition
SELECT * FROM employees WHERE NOT (job_id IS NULL) ORDER BY employee_id;
SELECT * FROM employees WHERE NOT (salary BETWEEN 1000 AND 2000) ORDER BY employee_id;
Logical AND condition
The logical AND condition indicates "and". It connects two conditions. If both conditions are TRUE, TRUE is returned. If either condition is FALSE, FALSE is returned. Otherwise, UNKNOWN is returned.
Examples of the logical AND condition
SELECT * FROM employees WHERE job_id = 'PU_CLERK' AND department_id = 30 ORDER BY employee_id;
Logical OR condition
The logical OR condition indicates "or". This means that either condition is valid. If either condition is TRUE, TRUE is returned. If both conditions are FALSE, FALSE is returned. Otherwise, UNKNOWN is returned.
Examples of the logical OR condition
SELECT * FROM employees WHERE job_id = 'PU_CLERK' OR department_id = 10 ORDER BY employee_id;