去重語句

老w愛db發表於2022-11-11

1. 查詢重複資料:

2. 指令碼如下:

DELETE from 表 WHERE (欄位) IN ( SELECT 欄位 FROM 表 GROUP BY 欄位 HAVING COUNT(欄位) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM 表 GROUP BY 欄位 HAVING COUNT(*) > 1);

3.修改指令碼:

 DELETE from card_imp

 WHERE (cardno) IN (SELECT cardno FROM card_imp GROUP BY cardno HAVING COUNT(cardno) > 1)

   AND ROWID NOT IN

       (SELECT MIN(ROWID) FROM card_imp GROUP BY cardno HAVING COUNT(*) > 1);

4.查詢結果:


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70021989/viewspace-2922843/,如需轉載,請註明出處,否則將追究法律責任。

相關文章