我在Windows上的mysql客户端 shell 中运行了它。我不明白问题是什么。我知道delete from PageInfo where id
是正确的。我知道子查询是正确的。我认为in是正确的,但是我不经常使用它。这整个事情看起来正确,但是我在某处遇到问题。我不明白该错误信息。
如何删除子查询返回的所有ID?
mysql> delete from PageInfo where id in ( select max(id) from PageInfo where pid
>=2758000 AND pid<2758100 group by pid having count(pid)>1 );
ERROR 1093 (HY000): You can't specify target table 'PageInfo' for update in FROM
clause
最佳答案
在MySQL中,您不能修改属于子查询的同一表。
有关更多信息,请访问http://dev.mysql.com/doc/refman/5.6/en/update.html
Workaround for your problem is described here.