LeetCode 196. Delete Duplicate Emails
考点 | 难度 |
---|---|
Database | Easy |
题目
Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id.
Return the result table in any order.
思路
用delete
删掉重复的email。
答案
DELETE p1
FROM Person p1, Person p2
WHERE p1.Email = p2.Email AND
p1.Id > p2.Id;