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.
INTERVALBINARY, COLLATE!- (unary minus), ~ (unary bit inversion)^*, /, DIV, %, MOD-, +<<, >>&|= (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, INBETWEEN, CASE, WHEN, THEN, ELSENOT&&, ANDXOR||, OR= (assignment), :=
The precedence of
= depends on whether it is used as a comparison operator (
=) or as an assignment
used as a comparison operator, it has the same precedence as
IN. When used as an assignment operator, it has the same precedence as
:=. Section 13.7.4, "
SET Syntax", and Section 9.4,
"User-Defined Variables", explain how MySQL determines which interpretation of
= should apply.
The meaning of some operators depends on the SQL mode:
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:
SELECT 1+2*3;-> 7mysql>
SELECT (1+2)*3;-> 9