1、最简单的是使用distinct,去除所有查询字段信息一样的数据
—————————————以下为有主键的情况下使用
2、 查询,去重,保留最小id信息
select * from people where id in (
select MIN(id) from people group by name,sex)
3、 查询全部的重复信息
select * from people where id not in (
select min(id) from people group by name,sex HAVING COUNT(*) < 2)
4、查询多余的重复信息
select * from people where id not in (
select MIN(id) from people group by name,sex)
5、删除多余重复的信息,只保留最小ID
delete from people where id not in(
select MIN(id) from people group by name,sex
)