You can't specify target table 'table' for update in FROM clause

Posted cralor

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了You can't specify target table 'table' for update in FROM clause相关的知识,希望对你有一定的参考价值。

delete from table1 where 
ID not in(select max(ID) ID from table1 group by row1) and 
row1 in (select row1from table1 group by row1 having count(*) > 1)
# 出现错误
#    You cant specify target table t_zqqk_stockinfo_copy2 for update in FROM clause

  不能从子句中指定目标表“TY-ZQQKYStknfOfCopy2”用于更新

 

delete from table1 where 
ID not in(select ID from (select max(ID) ID from table1 group by row1) as t1) and 
row1 in (select row1 from(select row1 from table1 groupby row1 havingcount(*) >1)as t2 )

 

子查询前再加一个子查询即可

 

技术分享图片

 


以上是关于You can't specify target table 'table' for update in FROM clause的主要内容,如果未能解决你的问题,请参考以下文章

You can't specify target table 'table' for update in FROM clause

You can't specify target table 'xxx' for update in FROM clause

mysql You can't specify target table 'xxx' for update in FROM clause的解决

You can't specify target table 't_mail_marketing' for update in FROM clause

You can't specify target table '表名' for update in FROM clause”解决方法

You can't specify target table 'e' for update in FROM clause