码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-05-26 17:12:25      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:div   can   错误   get   height   select   tar   技术分享   1.5   

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

标签:div   can   错误   get   height   select   tar   技术分享   1.5   

原文地址:https://www.cnblogs.com/cralor/p/9093532.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!