Home >Database >Mysql Tutorial >Mysql method to delete duplicate data
This article mainly introduces MysqlDeleteduplicate data Mysql data deduplication, friends in need can refer to
MySQL DatabaseQueryDuplicate data
select * from employee group by emp_name having count (*)>1;
Mysql Query the duplicate data that can be deleted
select t1.* from employee t1 where (t1.emp_name) in (select t4.emp_name from (select t2.emp_name from employee t2 group by t2.emp_name having count(*)>1) t4) and t1.emp_id not in (select t5.emp_id from (select min(t3.emp_id) as emp_id from employee t3 group by t3.emp_name having count(*)>1) t5);
Mysql Delete duplicates Data
delete t1 from employee t1 where (t1.emp_name) in (select t4.emp_name from (select t2.emp_name from employee t2 group by t2.emp_name having count(*)>1) t4) and t1.emp_id not in (select t5.emp_id from (select min(t3.emp_id) as emp_id from employee t3 group by t3.emp_name having count(*)>1) t5);
The above is the detailed content of Mysql method to delete duplicate data. For more information, please follow other related articles on the PHP Chinese website!