当前位置:首页 > 技术教程 > 正文

Mysql中不能update自身的解决方法

今天介绍一下Mysql中不能update自身的解决方法:

问题:

Mysql中不能update自身的解决方法 第1张

Mysql中不能update自身的解决方法 第2张

无法执行:

Mysql中不能update自身的解决方法 第3张

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小时不间断售后运维技术支持,专业备案团队全力支持。
产品购买地址: https://www.kufanyun.com/server/buy.html

0