我在 Windows 上的 mysql 客户端 shell 中运行了它。我不明白问题出在哪里。我知道 从 PageInfo 中删除 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
最佳答案
你可以这样做
delete from PageInfo where id = ( SELECT maxid FROM ( select max(id) as maxid from PageInfo where pid >=2758000 AND pid<2758100 group by pid having count(pid)>1) as tmp)
关于mysql - delete from where id in subquery 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12994768/