--查詢姓名、性別、年齡、地址、電話相同的員工記錄。
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);