LeetCode 196. Delete Duplicate Emails (删除重复的电子邮箱)

题目标签:

  题目给了我们一个 email 的表格,让我们删除重复的。

  建立Person p1,Person p2,当email 相同时,而且 p1 id 要大于 p2 id 时候,删除这一行。

Java Solution:

Runtime:  869 ms, faster than 33 %

Memory Usage: N/A

完成日期:06/01/2019

关键点:p1.Id > p2.Id

# Write your MySQL query statement below
DELETE p1
FROM Person p1, Person p2
WHERE p1.Email = p2.Email AND p1.Id > p2.Id;

参考资料:LeetCode Solution

LeetCode 题目列表 - LeetCode Questions List

题目来源:https://leetcode.com/

原文地址:https://www.cnblogs.com/jimmycheng/p/11444497.html

时间: 2024-10-09 02:13:01

LeetCode 196. Delete Duplicate Emails (删除重复的电子邮箱)的相关文章

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] 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 196. Delete duplicate Emails. (Database)

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 182. Duplicate Emails (查找重复的电子邮箱)

题目标签: 题目给了我们一个 email 的table,让我们找到重复的 email. 可以建立 Person a, Person b, 找到两个表格中,emai 相等 但是 id 不同的 email, 然后利用DISTINCT 返回,因为两个表格中,会找到两个 重复的email. Java Solution: Runtime:  224 ms, faster than 40 % Memory Usage: N/A 完成日期:06/01/2019 关键点:用DISTINCT # Write yo

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 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

196. 删除重复的电子邮箱

题目描述 编写一个 SQL 查询,来删除 Person 表中所有重复的电子邮箱,重复的邮箱里只保留 Id 最小 的那个. +----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protected] | | 2 | [email protected] | | 3 | [email protected] | +----+------------------+ Id是这个表的主键. 例如,在运行你

SQL 删除重复的电子邮箱

编写一个 SQL 查询,来删除 Person 表中所有重复的电子邮箱,重复的邮箱里只保留 Id 最小 的那个. +----+------------------+ | Id | Email | +----+------------------+ | 1 | john@example.com | | 2 | bob@example.com | | 3 | john@example.com | +----+------------------+ Id 是这个表的主键. 例如,在运行你的查询语句之后,

LC-196 删除重复的电子邮箱

主要目标: 把表中的重复数据清除掉 思路: 先建一个表to_delete,用来保存查找出来的重复的数据记录 然后利用这个to_delete表去删除Person表中的重复记录 记得最后删除这个临时表to_delete,另外,创建to_delete时,不能使用temporary table. 参考链接: SQL查找删除重复行 原文地址:https://www.cnblogs.com/leo-lzj/p/9612749.html