A logical condition combines two conditions to generate a single result or reverse the result of a single condition.
Logical conditions are NOT, AND, and OR.
NOT
The logical condition NOT can reverse the result of a single condition.
Judgment rules
If the result of the condition is FALSE, TRUE is returned. If the result of the condition is TRUE, FALSE is returned. If the result of the condition is UNKNOWN, UNKNOWN is returned.
Sample NOT condition
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;
AND
The logical condition AND combines two conditions.
Judgment rules
If the results of both conditions are TRUE, TRUE is returned. If the result of either condition is FALSE, FALSE is returned. If the result of one condition is UNKNOWN and that of the other is FALSE, FALSE is returned. Otherwise, UNKNOWN is returned.
Sample AND condition
SELECT * FROM emp WHERE job_id = 'PU_CLERK' AND dept_id = 32 ORDER BY empno;
OR
The logical condition OR evaluates whether either condition is true.
Judgment rules
If the result of either condition is TRUE, TRUE is returned. If the results of both conditions are FALSE, FALSE is returned. Otherwise, UNKNOWN is returned.
Sample OR condition
SELECT * FROM emp WHERE job_id = 'PU_CLERK' OR dept_id = 10 ORDER BY empno;