LeetCode

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

   删除重复的Email地址,保留Id最小的那个。

   使用自身连接循环即可。

# Write your MySQL query statement below
delete p1 from Person p1, Person p2
where p1.Email=p2.Email and p1.Id>p2.Id;
原文地址:https://www.cnblogs.com/wxisme/p/4440175.html