今天介绍一下Mysql中不能update自身的解决方法:
问题:
无法执行:
update bi_data.order_all_detail set err_msg='同时存在于wx,zfb平台',proc_time=now() where order_no in ( select order_no from bi_data.order_all_detail group by order_no having count(distinct platform)>1 )
提示:1093 – You can’t specify target table ‘order_all_detail’ for update in FROM clause
解决方法:
再加一层子查询:
update bi_data.order_all_detail set err_msg='同时存在于wx,zfb平台',proc_time=now() where order_no in ( select order_no from ( select order_no from bi_data.order_all_detail group by order_no having count(distinct platform)>1 ) tt )
以上就是关于“ Mysql中不能update自身的解决方法”的相关解答,若有不清楚的可以咨询酷番云,酷番云作为云南为数不错持有ICP/ISP/IDC等资质专业云计算提供商之一,成本控制良好,性价比高!提供各类云服务器产品及ICP备案一站式服务,操作简单快捷,7*24小时不间断售后运维技术支持,专业备案团队全力支持。
图片来源于AI模型,如侵权请联系管理员。作者:路飞,如若转载,请注明出处:https://www.kufanyun.com/ask/1277.html