Mysql處理重複資料
阿新 • • 發佈:2021-02-05
技術標籤: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;