删除 - 我无法指定目标表?
为什么这个查询不起作用?
DELETE FROM recent_edits
WHERE trackid NOT IN
(SELECT DISTINCT history.trackid
FROM history JOIN recent_edits ON history.trackid=recent_edits.trackid
GROUP BY recent_edits.trackid)
我收到此消息:“您无法在 FROM 子句中指定用于更新的目标表“recent_edits”
Why this query doesn't work?
DELETE FROM recent_edits
WHERE trackid NOT IN
(SELECT DISTINCT history.trackid
FROM history JOIN recent_edits ON history.trackid=recent_edits.trackid
GROUP BY recent_edits.trackid)
I get this message : "You can't specify target table "recent_edits" for update in FROM clause
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试用这种方法
Try in this way
您无法对锁定删除的表进行后处理。正如 Nicola 所说,使用 hack
select * from (query)
将生成一个临时表而不是直接访问。编辑 - 确保为您使用的表提供 ID,因为它是嵌套的,并且每个表都需要 uniqueID。
You can't post-process a table which is locked for deletion. using the hack
select * from (query)
as Nicola states will generate a temporary table instead of direct access.Edit - make sure that you give ID to the tables you use since it is nested and will require uniqueID for every table.