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;

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response