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 can't 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 )

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

猜你喜欢

转载自www.cnblogs.com/cralor/p/9093532.html