Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.
Person
Note:
Your output is the whole Person table after executing your sql. Use delete statement.
delete
GeeksforGeeks
Leetcodearrow-up-right
ProgramCreek
YouTube
Input:
Id
Email
1
[email protected]
2
3
Id is the primary key column for this table.
Output:
Last updated 5 years ago
# MySQL query statement DELETE p1 FROM Person p1, Person p2 WHERE p1.Email = P2.Email AND p1.Id > p2.Id