MySQL 刪除重複資料

有一重複會員資料表,要刪除相同 Email 及 生日 資料。

查詢:

Select * from users

order by email, birth;

確認重複內容:

select email, birth count(*) as cnt

from users

group by email, birth having cnt > 1;

刪除重複:

delete t1 from users as t1

inner join users as t2

where t1.id > t2.id

and t1.email = t2.email

and t1.birth = t2.birth;

--

--