ホームページ >データベース >mysql チュートリアル >重複データを削除するMysqlメソッド

重複データを削除するMysqlメソッド

怪我咯
怪我咯オリジナル
2017-07-05 11:07:311425ブラウズ

この記事では主に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 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。