Rules for ESQL operator precedence
How ESQL calculates expressions involving more than one operator.
When an expression involves more than one operator, the order in which the expression is evaluated might affect the result. Consider the following example:
SET a = b + c * d;
Under ESQL's precedence rules, c is multiplied by d and the result is added to b. This rule states that multiplication takes precedence over addition, so reordering the expression as follows:
SET a = c * d + b;
makes no difference. ESQL's precedence rules are set out later in this section, but it is generally considered good practice to use parentheses to make the meaning clear. The order of precedence is:
- Parentheses
- Unary operators including unary - and NOT
- Multiplication and division
- Concatenation
- Addition and subtraction
Operations at the same level are evaluated from left to right.