1093 - You can't specify target table 'api' for update in FROM clause
翻译:
您不能在 FROM 子句中指定目标表 ‘Table’ 进行更新
白话:
你不能先查询这个表得出的结果作为条件来修改这张表的数据。
例:
update a set name = null where id in (
select id from a where id>3)
修改:
update a set name = null where id in (
select id from (select id from a where id>3) b)
在SQL中,你不能直接在UPDATE语句的FROM子句中引用要更新的同一张表。这会导致错误。正确做法是使用子查询。例如,如果你想更新表A中id大于3的记录,将名称设为null,你应该这样做:
5059

被折叠的 条评论
为什么被折叠?



