【MySQL】1093 You can't specify target table 'table name' for update in FROM clause

来源:互联网 发布:史记的地位 知乎 编辑:程序博客网 时间:2024/04/30 19:59

错误 :1093 You can’t specify target table ‘table name’ for update in FROM clause
中文意思:不能先select出同一表中的某些值,再update这个表(在同一语句中)

解决:
注:把同一个table重新包一遍,重命名

原句

update  person_level_test  set currentStatus=0where id=(select max(m.id) from  person_level_test)

修改后

update  person_level_test  set currentStatus=0where id=(select max(m.id) from (select * from person_level_test) m)

转自http://www.cnblogs.com/lteal/archive/2013/05/06/3062709.html

0 0
原创粉丝点击