Im between cherry

Leet Code | MySQL | 196. Delete Duplicate Emails 본문

데이터분석/practice_query

Leet Code | MySQL | 196. Delete Duplicate Emails

meal 2020. 8. 30. 14:18

196. Delete Duplicate Emails

https://leetcode.com/problems/delete-duplicate-emails/

 

Delete Duplicate Emails - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.

 

 

DELETE p1
FROM person p1
    INNER JOIN person p2 ON p1.email = p2.email
WHERE p1.Id > p2.Id

 

Comments