mysql查询重复记录、删除重复记录方法

查找所有重复标题的记录:

SELECT * FROM t_info a WHERE ((SELECT COUNT(*) FROM t_info WHERE Title = a.Title) > 1) ORDER BY Title DESC

查找全部重复记录

Select * From 表 Where 重复字段 In (Select 重复字段 From 表 Group By 重复字段 Having Count(*)>1)

过滤重复记录(只显示一条)

Select * From HZT Where ID In (Select Max(ID) From HZT Group By Title)

注:此处显示ID最大一条记录

查找表中多余的重复记录(多个字段)

select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)

查找表中多余的重复记录(多个字段),不包含rowid最小的记录

select * from eva a where (a.taskId,a.proId) in (select taskId,proId from eva group by taskId,proId having count(*) > 1)
and id not in (select min(id) from eva group by taskId,proId having count(*)>1)

 

 

 

 

你可能感兴趣的:(mysql与mycat)