Mysql: Table name is specified twice, both as a target for UPDATE and as a separate source for data

版权声明:本文为博主原创文章,若转载请加上此页地址。 https://blog.csdn.net/macwhirr123/article/details/79387855

执行SQL:

update table1 set status2=1 where id IN( select max(id) from table1 where cid=1 group by link)  ;

出现错误:

Mysql: Table name is specified twice, both as a target for UPDATE and as a separate source for data


将SQL修改为:

update table1 set status2=1 where id IN(select * from ( select max(id) from table1 where cid=1 group by link) as TEMP ) ;


猜你喜欢

转载自blog.csdn.net/macwhirr123/article/details/79387855
今日推荐