Mysql Error Code: 1093

本文介绍了一种在MySQL中批量修改数据时出现的错误,ErrorCode:1093,该错误源于在更新语句中不当使用了子查询。通过调整子查询结构,将内层查询结果作为临时表使用,成功解决了这一问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

批量修改,带有子查询语句,报错 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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值