1樓:
delete from @t where id not in(select id from(select address,min(id) id from @t group by address) t2)
把@t改成你的表名
這句可以實現,不過用的是最笨的辦法
2樓:匿名使用者
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,沒法驗證... 樓主試試先
3樓:匿名使用者
用迴圈判斷!效率可能不高!
<%sql="select * from ok"
set rs=conn.execute(sql)do until rs.eof
<>"&rs(0)
rs1.open sqk,conn,1,1if rs1.recordcount>
conn.execute(sqm)
end if
rs1.close
rs.movenext
loop
%>我也沒法驗證,不好意思,思路基本這樣的
1、首先搜出資料庫所有記錄
2、讀取第一條去對比資料中除了自己的所有記錄,如果有相同的那麼就把這條刪除。
3、迴圈讀第二條,再照此判斷。
sql怎麼不重複記錄,sql 怎麼查詢不重複資料
alter table table a add purchase price number a表沒有purchase price列 首先給表a加一列。insert into table a purchase price select purchase price from select table ...
mysql查詢結果中有多條重複記錄只保留一條
這個需要分情況。1,你的資料庫表中有主鍵,且主鍵上面的資料為唯一值。也就是沒有重複值。那麼你在刪除的時候,將這個唯一值作為條件進行刪除。如果是完全重複的話可以用distinct關鍵字去重。sql檢索,但檢索結果中有某欄位內容重複的資料只保留1條顯示 檢索結果有漏掉?請樓主舉例 我用聯合查詢的例子,樓...
SQL查詢多條符合條件的記錄,SQL查詢滿足兩個條件的重複記錄只顯示2條記錄的方法
select from table where column a in select 條件n from table where 總之你的多個 條件 如果能用select出來的話,把結果放到in裡就可以了。查詢符合條件的記錄,關鍵字 where 假如 表 table 中有3個字段,t1,t2,t3並且...