经典sql
--查找重复记录
select a.* from stu as a,(select name,pwd from stu group by name,pwd having count(*)>1) b where a.name = b.name and a.pwd = b.pwd
--查找未重复记录
select a.* from stu as a,(select name,pwd from stu group by name,pwd having count(*)=1) b where a.name = b.name and a.pwd = b.pwd
--删除重复记录
delete stu where id in(select id from stu as a,(select name,pwd from stu group by name,pwd having count(*)>1) b where a.name = b.name and a.pwd = b.pwd
)
--删除重复记录(保留一条)
select distinct name,pwd into temp from stu
drop table stu
select * into stu from temp
drop table temp
浙公网安备 33010602011771号