-
update a set col=(select col from a where id='5') where id>5 and id<10;
报错了
ERROR 1093 (HY000): You can't specify target table 'a' for update in FROM clause
经过研究
发现是 mysql 定义update语句不能同时对同一张进行set 赋值操作,也就是说
update a 的时候 不能在后面select col from a ,如果是不同表操作是没有问题的。
想到一个解决方法:
-
update a set col=(select col from (select * from a ) as b where id='5' )where id>5 and id <10;
将select那里的a的表起一个别名b 就可以解决这个问题
update mem_player set `DataWarehouse`=(select `DataWarehouse` from (select * from mem_player) as b where `Pid`=100000)
阅读(14163) | 评论(0) | 转发(0) |