Operator Precedence

An expression is a combination of literal values, variables, operators and functions.

Precedence and associativity determine the evaluation order of the operators.

Operators with higher precedence are evaluated first.

The associativity determines the direction in which operators of the same precedence are evaluated.

Operator Precedence Table

Precedence Operator Associativity
1 + (Unary plus), - (Unary minus), ~ (Unary Bitwise NOT) Right-to-left
2 * (Multiply), / (Division), % (Modulo) Left-to-right
3 + (Add, Concatenate), - (Subtract), & (Bitwise AND), ^ (Bitwise XOR), | (Bitwise OR) Left-to-right
4 =, >, <, >=, <=, <>, !=, !>, !< (Comparison) Left-to-right
5 IS NULL, LIKE, BETWEEN, IN, ALL, ANY, SOME Left-to-right
6 NOT (Unary Logical Not) Right-to-left
7 AND (Logical And) Left-to-right
8 OR (Logical Or) Left-to-right
RSQL, a simple alternative to Microsoft SQL Server