同求指点mysql> select 1+@t:=4; +---------+ | 1+@t:=4 | +---------+ | 5 | +---------+ 1 row in set (0.00 sec)mysql> select (1+@t):=4; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':=4' at line 1
+---------+
| 1+@t:=4 |
+---------+
| 5 |
+---------+
1 row in set (0.00 sec)mysql> select (1+@t):=4;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':=4' at line 1
@t1:=(@t2:=1)+@t3
@t1:=@t2+@t3
mysql> SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
+----------------------+------+------+------+
| @t1:=(@t2:=1)+@t3:=4 | @t1 | @t2 | @t3 |
+----------------------+------+------+------+
| 5 | 5 | 1 | 4 |
+----------------------+------+------+------+以上内容都是操作手册里的内容,求解释另:能找到个讨论问题的地方真好。
1 ||, OR, XOR
2 &&, AND
3 BETWEEN, CASE, WHEN, THEN, ELSE
4 =, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN
5 |
6 &
7 <<, >>
8 -, +
9 *, /, DIV, %, MOD
10 ^
11 - (unary minus), ~ (unary bit inversion)
12 !, NOT
最低优先级 BINARY, COLLATE
12.1.1. 操作符优先级
以下列表显示了操作符优先级的由低到高的顺序。排列在同一行的操作符具有相同的优先级。 :=||, OR, XOR&&, ANDNOTBETWEEN, CASE, WHEN, THEN, ELSE=, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN|&<<, >>-, +*, /, DIV, %, MOD^- (一元减号), ~ (一元比特反转)!BINARY, COLLATE