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
)
本文来自博客园,作者:xiaoyongdata(微信号:xiaoyongdata),转载请注明原文链接:https://www.cnblogs.com/xiaoyongdata/p/15628081.html