MySQL基础学习-查询、删除表中重复的数据


原表数据:

1. 查询表中存在的重复数据的次数:select 展示字段,count(*)  from 表 group by 查询字段 having count(*/查询字段) >1;

2. 显示表中重复的数据:select * from table_name where 查询字段 in (select name from table_name group by count(查询字段)>1);

3. 查询多个字段重复:select * from table_name,table_b where (b.查询字段1,b.查询字段2) in (select 查询字段1,查询字段2 from table_name group by  查询字段1,查询字段2 having count(*)>1);

4. 删除表中重复数据:delete from table_name where 重复字段名 in (select 重复字段名 from table_name group by 重复字段名 having count(重复字段名)>1);

未待完续。。。(如有错误,请大佬指出。。。)