今天介绍一下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 )
图片来源于AI模型,如侵权请联系管理员。作者:路飞,如若转载,请注明出处:https://www.kufanyun.com/ask/1277.html
