删除多列同时重复数据

delete A from Table A where exists(select count(*)c from Table B  where  A.col1=B.col1 and A.col2=B.col2 having count(*)>1)

注意 delete 后面的A必写,不然会报错 

如果用in的话便是

delete from Table A where col1+col2 in (select col1+col2 from table1 group by col1+col2 having count(*)>1)

但用in的话效率会比较低,不能用索引 

posted @ 2016-03-30 11:22  xjt360  阅读(439)  评论(0编辑  收藏  举报