這篇文章主要介紹了Mysql刪除重複的資料Mysql資料去重複,需要的朋友可以參考下
select * from employee group by emp_name having count (*)>1;
Mysql 查詢可以刪除的重複資料
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 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刪除重複的資料的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!