問題:發現存在一張表中存在相同的兩行數據
得到:僅僅保留一行數據
方法:
原理-我們通過
1 select count (字段1,字段2) from 表1; 2 3 結果 200條數據 4 5 select count (distinct 字段1,字段2) from 表1; 6 7 結果 100條數據 8 9 相當於后者可以實現查出來去重后的數據 10 11 create table 表1_bak as select distinct 字段1,字段2 from 表1; --備份表數據 12 13 delete from 表1; 14 15 insert into 表1 select * from 表1_bak;