标签:style blog http color ar sp 数据 div log
查询及删除重复记录的SQL语句
转自: http://www.cnblogs.com/252e/archive/2012/09/13/2682817.html
select * from ops_service_relate a where (a.SERVICE_ID,a.RELATE_ID,a.RELATE_TYPE) in (select SERVICE_ID,RELATE_ID,RELATE_TYPE from ops_service_relate group by SERVICE_ID,RELATE_ID,RELATE_TYPE having count(*) > 1) and rowid not in (select min(rowid) from ops_service_relate group by SERVICE_ID,RELATE_ID,RELATE_TYPE having count(*)>1)
delete from ops_service_relate a where (a.SERVICE_ID,a.RELATE_ID,a.RELATE_TYPE) in (select SERVICE_ID,RELATE_ID,RELATE_TYPE from ops_service_relate group by SERVICE_ID,RELATE_ID,RELATE_TYPE having count(*) > 1) and rowid not in (select min(rowid) from ops_service_relate group by SERVICE_ID,RELATE_ID,RELATE_TYPE having count(*)>1);
标签:style blog http color ar sp 数据 div log
原文地址:http://www.cnblogs.com/yangw/p/4088086.html