delete a from 表1 a where exists(select 1 from 表1 where id=a.id and name<a.name)
select a.* from tb a,(select id,min(name) as name from tb group by id) b where b.id=a.id and b.name=a.name
我要的是删除库的结果,不是select语句,可libin_ftsafe的方法调不通
delete from 表1 as a ,(select top 1 id name from 表1 group by id) as b where a.id=c.id and a.name<>b.name
借别人的一用,:) delete a from 表1 a where exists(select 1 from 表1 where id=a.id and name<a.name)
建一个临时表 insert into biao2(id,name ......) select top 1 id,name ...... from 表1 group by id delete from 表1insert into 表1(id,name ......) select id,name ...... from biao2
where a.id=c.id and a.name<>b.name
delete a from 表1 a where exists(select 1 from 表1 where id=a.id and name<a.name)
insert into biao2(id,name ......) select top 1 id,name ...... from 表1 group by id
delete from 表1insert into 表1(id,name ......) select id,name ...... from biao2
回复人: libin_ftsafe(子陌红尘) ( ) 信誉:105哎以后看帖,应该多看,多想,再动手
http://community.csdn.net/Expert/topic/4426/4426368.xml?temp=.8434717
差不多。。
where a.name <>(select top 1 name from [表1] b
where b.id=a.id)
--------------------------------
若NAME出现重复,则该办法不能用