delete from @t where id not in(select id from(select address,min(id) id from @t group by address) t2)
把@t改成你的表名
这句可以实现,不过用的是最笨的办法
delete from tablename where id not in (select top 1 id from tablename as a where (select count(*) from tablename as b where a.address = b.address)>1)
没装sql,没法验证... 楼主试试先
用循环判断!效率可能不高!
<%
sql="select * from ok"
set rs=conn.execute(sql)
do until rs.eof
sqk="select * from ok where address='"&rs("address")&"' and id<>"&rs(0)
rs1.open sqk,conn,1,1
if rs1.recordcount>0 then
sqm=delete * from ok where id="&rs1(0)
conn.execute(sqm)
end if
rs1.close
rs.movenext
loop
%>
我也没法验证,不好意思,思路基本这样的
1、首先搜出数据库所有记录
2、读取第一条去对比数据中除了自己的所有记录,如果有相同的那么就把这条删除。
3、循环读第二条,再照此判断。