All Products
Search
Document Center

PolarDB:Logical operators

Last Updated:Mar 28, 2026

PolarDB for Oracle supports three logical operators: AND, OR, and NOT. SQL uses three-valued Boolean logic, where null represents unknown. This means that expressions involving null do not always evaluate to TRUE or FALSE.

Operator signatures

Each operator accepts Boolean inputs and returns a Boolean result:

boolean AND boolean → boolean
boolean OR  boolean → boolean
NOT boolean         → boolean

Truth tables

AND/OR

aba AND ba OR b
TRUETRUETRUETRUE
TRUEFALSEFALSETRUE
TRUENULLNULLTRUE
FALSEFALSEFALSEFALSE
FALSENULLFALSENULL
NULLNULLNULLNULL

NOT

aNOT a
TRUEFALSE
FALSETRUE
NULLNULL

Examples

-- AND: returns rows where both conditions are true
SELECT * FROM employees WHERE job_id = 'PU_CLERK' AND department_id = 30;

-- OR: returns rows where either condition is true
SELECT * FROM employees WHERE job_id = 'PU_CLERK' OR department_id = 10;

-- NOT: returns rows where the condition is false
SELECT * FROM employees WHERE NOT (job_id IS NULL);

Commutativity

AND and OR are commutative — switching the left and right operands does not affect the result.