Mysql刪除重復的數據的方法
發表時間:2023-08-24 來源:明輝站整理相關軟件相關文章人氣:
[摘要]這篇文章主要介紹了Mysql刪除重復的數據 Mysql數據去重復,需要的朋友可以參考下MySQL數據庫中查詢重復數據select * from employee group by emp_name having count (*)>1;Mysql 查詢可以刪除的重復數據select t1....
這篇文章主要介紹了
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中文網其它相關文章!
學習教程快速掌握從入門到精通的SQL知識。