Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit e8444d5

Browse files
delete-duplicate-emails
1 parent fdeec3c commit e8444d5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎MySQL/delete-duplicate-emails.sql‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Time: O(n^2)
22
# Space: O(n)
33

4-
DELETE p1
5-
FROM Person p1, Person p2
6-
WHERE p1.Email = p2.Email AND p1.Id > p2.Id
4+
DELETE FROM person
5+
WHERE id NOT IN (
6+
SELECT sub.min_id
7+
FROM(
8+
SELECT Email, MIN(ID) AS min_id
9+
FROM Person
10+
GROUP BY Email
11+
) sub)
712

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /