题目链接
delete duplicate emails
解法
delete p1 from Person p1
where p1.id not in
(
select id from (select min(p2.id) as id
from Person p2
group by email) as p
)
注意事项
min(id)
把column name改成了min(id)
了,需要重新rename为id
- 需要创建一个temporary (intermediate) table
p
来保证删除table Person
的同时不更改原table