mysql 查询并删除重复的记录

1.查询重复的用户名记录

select user_name,count(*) as count from user group by user_name having count>1;

2.查找表中全部重复的记录

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

 

3.过滤重复记录只显示一条

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

4.删除重复的记录 保存最小的

Delete Table Where ID Not In (Select Max(ID) From Table Group By Title)

 

你可能感兴趣的:(MySQL)