日期:2014-05-16 浏览次数:20742 次
mysql> select * from test; +------+------+ | id | col2 | +------+------+ | 1 | 2 | | 2 | 1 | | 1 | 3 | | 3 | 14 | +------+------+ 4 rows in set (0.00 sec) mysql> select max(col2) into @col2 from test;update test set col2=@col2+10 where id=3; Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from test; +------+------+ | id | col2 | +------+------+ | 1 | 2 | | 2 | 1 | | 1 | 3 | | 3 | 24 | +------+------+ 4 rows in set (0.00 sec)
------解决方案--------------------
UPDATE fanwe_share,(select max(px)+1 AS MA from fanwe_share) B
SET A.px =B.MA WHERE share_id = 2
------解决方案--------------------