首頁  >  文章  >  資料庫  >  Mysql刪除重複的資料的方法

Mysql刪除重複的資料的方法

怪我咯
怪我咯原創
2017-07-05 11:07:311337瀏覽

這篇文章主要介紹了Mysql刪除重複的資料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中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn