1、查找表中的重复记录,用字段(stud_stud_name)来判断
select * from students
where
stud_stud_name
in
(select stud_stud_name from students group by stud_stud_name having count(stud_stud_name)>1)
2、删除表中的重复记录
delete from students
where
stud_stud_name
in
(select stud_stud_name from students group by stud_stud_name having count(stud_stud_name)>1)
and
rowid
not in
(select min(rowid) from students group by stud_stud_name having count(stud_stud_name>1))
3、查找表中多余的重复记录(多个字段)
select * from students
where (stud_stud_name,stud_stud_age)
in
(select stud_stud_name,stud_stud_age from students group by stud_stud_name,stud_stud_age having count(*) > 1)
4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录
delete from students
where
(stud_stud_name,stud_stud_age)
in
(select stud_stud_name,stud_stud_age from students group by stud_stud_name,stud_stud_age having count(*) > 1)
and
rowid
not in (select min(rowid) from students group by stud_stud_name,stud_stud_age having count(*)>1)