我正在尝试更新 MySQL 行。
我的查询是
update x set available_material_id = null where id not in (select id from x where additional_info = 1);
我收到此错误消息:您无法在 FROM 子句中指定要更新的目标表“x”
有人可以帮我解决这个问题吗?
我使用的是 MySQL 版本 5.6.38。
我看到了这个You can't specify target table for update in FROM clause答案,但我无法弄清楚。
最佳答案
使用左连接
:
update x left join
x xx
on x.id = xx.id and xx.additional_info = 1
set available_material_id = null
where xx.id is null;
关于mysql - 更新 mysql 行时(您无法在 FROM 子句中指定目标表 'x' 进行更新),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51087937/