Skip to Main Content

Condition Precedence

Info from

Precedence is the order in which Oracle Database evaluates different conditions in the same expression. When evaluating an expression containing multiple conditions, Oracle evaluates conditions with higher precedence before evaluating those with lower precedence. Oracle evaluates conditions with equal precedence from left to right within an expression, with the following exceptions:
  • Left to right evaluation is not guaranteed for multiple conditions connected using AND
  • Left to right evaluation is not guaranteed for multiple conditions connected using OR

This table lists the levels of precedence among SQL condition from high to low. Conditions listed on the same line have the same precedence. As the table indicates, Oracle evaluates operators before conditions.
Type of Condition Purpose
SQL operators are evaluated before SQL conditions See "Operator Precedence"
=, !=, <, >, <=, >=, comparison
NOT exponentiation, logical negation
AND conjunction
OR disjunction

Info from

It is important to understand how the database evaluates multiple comparisons in the WHERE clause. All the AND comparisons (evaluated from Left to Right) are evaluated before the OR comparisons (evaluated from Left to Right).
For example:
As you read this query, it appears that you collect all the employees from the finance and sales department and then check that the salary is less than 1000000.
In this case, you would be wrong! The database will evaluate the AND before the OR.
What this query actually does is list employees in SALES with salary < 100000, and all the employees in the FINANCE department.

Nice example from

Just yesterday I got caught by this. Started with working code:    Changed it in haste:    Broke, because this is what I wanted:    But this is what I got: