标签:name res rom 最大的 count select where 重复 delete address having
--查找姓名、性别、年龄、地址、电话相同的员工记录。
select count(id) as id_count,
name,
sex,
birthday,
address,
tel
from staff
group by
name,
sex,
birthday,
address,
tel
having(count(*) > 1);
--删除姓名、性别、年龄、地址、电话相同的重复员工记录(保留ID最大的一条)。
delete staff where id not in (select max(id) from staff group by name, sex, birthday, address, tel);
标签:name res rom 最大的 count select where 重复 delete address having
原文地址:http://www.cnblogs.com/ego/p/3700995.html