MySQL follows operator precedence and it has the following list of operators, having the same precedence which is on the same line −
INTERVAL BINARY, COLLATE ! - (unary minus), ~ (unary bit inversion) ^ *, /, DIV, %, MOD -, + <<, >> & | =, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN BETWEEN, CASE, WHEN, THEN, ELSE NOT &&, AND XOR ||, OR :=
For operators that occur at the same precedence level within an expression, evaluation proceeds from left to right.
Example
Following is an example which shows the effect of operator precedence on result set −
mysql> Select 5+3/2-2; +---------+ | 5+3/2-2 | +---------+ | 4.5000 | +---------+ 1 row in set (0.00 sec)
In the above evaluation, MySQL first evaluates /(div) because it is at higher precedence than +(Addition) or –(Subtraction).