批量修改,带有子查询语句,报错 Error Code: 1093. You can't specify target table 't' for update in FROM clause 0.000 sec
错误的语句
update t_wx_menu t set
t.del_flag = 1,
t.update_time = now()
where t.id in (select b.id from t_wx_menu a join t_wx_menu b on a.id = b.pid where a.id = 19)
修改为:
update t_wx_menu t set
t.del_flag = 1,t.update_time = now()
where t.id in (select id from (select b.id AS id from t_wx_menu a join t_wx_menu b on a.id = b.pid where a.id = 19) as temtable)
本文介绍了一种在MySQL中批量修改数据时出现的错误,ErrorCode:1093,该错误源于在更新语句中不当使用了子查询。通过调整子查询结构,将内层查询结果作为临时表使用,成功解决了这一问题。
5173

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



