如:現有一張表名爲trojans,其中others字段很多是重複的,
刪除重複的記錄語句如下:
delete trojans from trojans , (select id from trojans GROUP by others having count(*)>1) as t2 where t2.id=trojans.id
這個語句一次只能刪除重複中的一條記錄,所以如果有n個重複記錄就要執行n-1遍
多字段分組
delete pcap from pcap ,(select id from pcap group by createdtime,horse,horseprot,horseregion having count(*) >1)as p2 where p2.id=pcap.id