从子查询错误中的 where id 中删除 [英] delete from where id in subquery error
问题描述
我在 Windows 上的 mysql 客户端 shell 中运行了它.我不明白问题是什么.我知道 delete from PageInfo where id
是正确的.我知道子查询是正确的.我认为 in 是正确的,但我不经常使用它.整个事情看起来是正确的,但我在某处遇到了问题.我不明白错误信息.
I ran this in mysql client shell on windows. I don't understand what the problem is. I know delete from PageInfo where id
is correct. I know the subquery is correct. I think in is correct but I don't use it that often. This entire thing looks correct but i get a problem somewhere. I don't understand the error message.
如何删除子查询返回的所有 ID?
How do i delete all the ids the subquery returns?
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 中,您不能修改作为子查询一部分的同一个表.
In MySQL you cannot modify the same table which is a part of subquery.
更多信息位于 http://dev.mysql.com/doc/refman/5.6/en/update.html
这篇关于从子查询错误中的 where id 中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!