从嵌套选择结果中删除问题
我写了这个查询:
delete from `test1` where id in (
SELECT id
FROM `test1`
GROUP BY m, n
HAVING count( id ) >1)
但是 mysql 给出了这个错误:
“你不能在 FROM 子句中指定用于更新的目标表“test1””
为什么?我该如何解决它?
i have written this query:
delete from `test1` where id in (
SELECT id
FROM `test1`
GROUP BY m, n
HAVING count( id ) >1)
but mysql gives this error:
'You can't specify target table 'test1' for update in FROM clause '
why? how can i solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在更新表,而选择正在进行中......这不是小菜一碟:-)
我建议首先选择 tmp 表,然后在第二个查询中删除。
You are updating table while select is in progress... THat' not a piece of cake :-)
I would suggest to select into tmp table first, and do delete in second query.