Table of Contents

About

The operations within an expression are evaluated in order of precedence. Operators with equal precedence are applied in no particular order.

This table show the operator from the highest to the lowest level.

Order Operator Operation
1 ** exponentiation
2 +, - identity, negation
3 *, / multiplication, division
4 +, -, || addition, subtraction, concatenation
5 =, <, >, <=, >=, <>, !=, ~=, ^=, IS NULL, LIKE, BETWEEN, IN comparison
6 NOT logical negation
7 AND conjunction
8 OR inclusion

You can use parentheses to control the order of evaluation. When parentheses are nested, the most deeply nested subexpression is evaluated first.

For instance, when NOT, AND and OR are used in the same statement :

  • NOT is evaluated first,
  • then AND,
  • and finally OR.

Reference