--查找姓名、性别、年龄、地址、电话相同的员工记录。

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);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2021-11-08
猜你喜欢
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2021-09-26
  • 2022-12-23
相关资源
相似解决方案