LeetCode - Delete Duplicate Emails

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;
时间: 2024-09-30 06:14:06

LeetCode - Delete Duplicate Emails的相关文章

[LeetCode] Delete Duplicate Emails 删除重复邮箱

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protected] | | 2 | [email protected]

[LeetCode][SQL]Delete Duplicate Emails

https://leetcode.com/problems/delete-duplicate-emails/ Delete Duplicate Emails Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Emai

leetcode 196. Delete Duplicate Emails

196. Delete Duplicate Emails Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protect

[LeetCode][SQL]Duplicate Emails

https://leetcode.com/problems/duplicate-emails/ Duplicate Emails Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Email | +----+---------+ | 1 | [email protected] | | 2 | [email protected] | | 3 | [email

【Leetcode】Duplicate Emails

题目链接:https://leetcode.com/problems/duplicate-emails/ 题目: Write a SQL query to find all duplicate emails in a table named Person. +--+---+ | Id | Email | +--+---+ | 1 | [email protected] | | 2 | [email protected] | | 3 | [email protected] | +--+---+ F

LeetCode:Duplicate Emails - 重复出现的Email

1.题目名称 Duplicate Emails(重复出现的Email) 2.题目地址 https://leetcode.com/problems/duplicate-emails/ 3.题目内容 有一个数据表包括Id和Email两列,找出数据表内Email列内容重复出现的Email数据. 例如,现有一个表Person内容如下: +----+---------+ | Id | Email   | +----+---------+ | 1  | [email protected] | | 2  | 

leetcode 182. Duplicate Emails

传送门 182. Duplicate Emails My Submissions Question Total Accepted: 14498 Total Submissions: 38364 Difficulty: Easy Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Email | +----+---------+ | 1 | [email pr

leetcode数据库sql之Delete Duplicate Emails

leetcode原文引用: Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protected] | | 2 | [em

【Leetcode】Delete Duplicate Emails

题目链接:https://leetcode.com/problems/delete-duplicate-emails/ 题目: Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +--+------+ | Id | Email | +--+------+ | 1 | [email