【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 protected] |

| 2 | [email protected] |

| 3 | [email protected] |

+—-+——————+

Id is the primary key column for this table.

For example, after running your query, the above Person table should have the following rows:

+—-+——————+

| Id | Email |

+—-+——————+

| 1 | [email protected] |

| 2 | [email protected] |

+—-+——————+

思路:

注意delete后面查询结构的用法。

算法:

delete p1 from Person p1 inner join Person p2 on p1.email=p2.email and p1.id>p2.id
时间: 2024-10-12 16:03:49

【Leetcode】Delete Duplicate Emails的相关文章

[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 Database: 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】Delete Node in a Linked List

原题链接:https://leetcode.com/problems/delete-node-in-a-linked-list/ 题目描述: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the

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

【leetcode】Contains Duplicate & Rectangle Area(easy)

Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. 思路:简单题用set bool cont

【LeetCode】Contains Duplicate II

Contains Duplicate II 问题描述 Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k. 算法思想 思想一: 两个数组下标i,j,在叫j-i<

【leetcode】1089. Duplicate Zeros

题目如下: Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array are not written. Do the above modifications to the input arr