1. 程式人生 > 其它 >Mysql處理重複資料

Mysql處理重複資料

技術標籤:MYSQL

資料表內容:

SELECT * FROM runoob.runoob_tbl;

在這裡插入圖片描述
統計runoob_title重複次數大於1的個數(HAVING子句設定重複數大於1。):

select count(runoob_title) as repetitions, runoob_title,runoob_author from runoob_tbl group by runoob_title having repetitions>1;

在這裡插入圖片描述
過濾重複runoob_title重複的列:

select runoob_title,runoob_author submisson_data from runoob_tbl group by runoob_title;

在這裡插入圖片描述
刪除重複資料:

create table tmp select * from runoob_tbl group by runoob_title;
drop table runoob_tbl;
alter table tmp rename to runoob_tbl;

在這裡插入圖片描述