Operator precedences are shown in the following list, from highest precedence to the lowest. Operators that are shown together on a line have the same precedence.
INTERVAL BINARY, COLLATE !, NOT - (unary minus), ~ (unary bit inversion) ^ *, /, DIV, %, MOD -, + <<, >> & | = (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN BETWEEN, CASE, WHEN, THEN, ELSE &&, AND XOR ||, OR = (assignment), :=
The precedence of = depends on whether it is
used as a comparison operator
(=) or as an
assignment operator
(=). When
used as a comparison operator, it has the same precedence as
<=>,
>=,
>,
<=,
<,
<>,
!=,
IS,
LIKE,
REGEXP, and
IN. When used as an assignment
operator, it has the same precedence as
:=.
Section 12.4.4, “SET Syntax”, and
Section 8.4, “User-Defined Variables”, explain how MySQL determines
which interpretation of = should apply.
The || operator has
a precedence between
^ and the
unary operators if the
PIPES_AS_CONCAT SQL mode is
enabled.
The precedence of operators determines the order of evaluation of terms in an expression. To override this order and group terms explicitly, use parentheses. For example:
mysql>SELECT 1+2*3;-> 7 mysql>SELECT (1+2)*3;-> 9

User Comments
Add your own comment.