要刪除重復的記錄,就要先查出重復的記錄,這個很容易做到
select * from 表名 group by 根據哪一個字段(簡稱字段) having count(字段) > 1
注意:這是查出所有重復記錄的第一條記錄,需要保留,因此需要添加查詢條件,查出所有的重復記錄
select id,expect from cqssc where expect in (select expect from cqssc group by expect having count(expect)>1) and id not in(select min(id) from cqssc group by expect having count(expect)>1)

然后
delete from cqssc where id in (select id from (select id from cqssc where expect in (select expect from cqssc group by expect having count(expect)>1) and id not in (select min(id) from cqssc group by expect having count(expect)>1)) as tmpresult)

刪除成功,最后再查詢一下看是否還有重復記錄

