operator priority
The priority of operators from high to low is shown below. Operators in the same line have equal precedence.
| Priority sort from high to low | Operator |
|---|---|
| 1 | INTERVAL |
| 2 | BINARY, COLLATE |
| 3 | ! |
| 4 | - (unary minus), ~ (unary bit inversion) |
| 5 | ^ |
| 6 | *, /, DIV, %, MOD |
| 7 | -, + |
| 8 | <<, >> |
| 9 | & |
| 10 | | |
| 11 | = (comparison), <=>, >=, >, <=, <, <, <>, !=, IS, LIKE, , IN, MEMBER OF |
| 12 | BETWEEN, CASE, WHEN, THEN, ELSE |
| 13 | NOT |
| 14 | AND, && |
| 15 | XOR |
| 16 | OR, || |
| 17 | = (assignment) |
The priority of the operator = depends on whether it is used as a comparison operator or an assignment operator. When used as a comparison operator, it has the same priority as >=, >, <=, <, <>, !=, IS, LIKE and IN().
For operators with the same priority in the expression, the evaluation will be calculated from left to right, but the assignment will be calculated from right to left.