[SQL]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 | john@example.com |
| 2 | bob@example.com |
| 3 | john@example.com |
+----+------------------+
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 | john@example.com |
| 2 | bob@example.com |
+----+------------------+
# Write your MySQL query statement below
delete p1
from Person p1,Person p2
where p1.Email=p2.Email
and p1.Id>p2.Id;
[SQL]196. Delete Duplicate Emails的更多相关文章
- leetcode【sql】 Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- 196. Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- leetcode 196. Delete Duplicate Emails
# 慢,内连接delete p1 from Person p1, Person p2 where p1.Email=p2.Email and p1.Id>p2.Id delete from Pe ...
- leetcode 196. Delete Duplicate Emails 配合查询的delete
https://leetcode.com/problems/delete-duplicate-emails/description/ 题意要对原来的数据表进行删除,不删除不行,它每次只输出原来那个表. ...
- LeetCode 196. Delete Duplicate Emails (删除重复的电子邮箱)
题目标签: 题目给了我们一个 email 的表格,让我们删除重复的. 建立Person p1,Person p2,当email 相同时,而且 p1 id 要大于 p2 id 时候,删除这一行. Jav ...
- [LeetCode] 196. Delete Duplicate Emails_Easy tag: SQL
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- [LeetCode] Delete Duplicate Emails 删除重复邮箱
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- LeetCode——Delete Duplicate Emails(巧用mysql临时表)
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- 【SQL】182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
随机推荐
- [csp-201509-3]模板生成系统
#include<bits/stdc++.h> using namespace std; ; string a[N],b[N],c[N]; int main() { //freopen(& ...
- Exp3:MAL_免杀原理与实践
目录 1.实验环境 2.实践内容 2.1 msfvenom 2.1.1 msfvenom直接生成 2.1.2 msfvenom 编码一次 2.1.3 msfvenom 编码多次 2.2 Veil_ev ...
- Cloud Lab: 泰晓实验云台【转】
转自:http://tinylab.org/cloud-lab/ 可快速构建的计算机课程在线实验平台 由 Wu Zhangjin 创建于 2017/10/06 评论 打赏 项目描述 泰晓实验云台 项目 ...
- 打包egg
scrapyd-deploy -p chahao -v 1.0 --build-egg chahao.egg
- ibm x3550m4 开启cpu高性能模式
1.必须进bios里调整,和调整超线程一样,重启服务器按F1进bios界面,选择system settings 2.选择最大性能模式:Operating Modes>Choose Operati ...
- HDU 2476 String painter(区间DP+思维)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2476 题目大意:给你字符串A.B,每次操作可以将一段区间刷成任意字符,问最少需要几次操作可以使得字符串 ...
- epoll测试实例
C++ Code 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...
- Unix IPC之Posix消息队列(2)
/* Query status and attributes of message queue MQDES. */ extern int mq_getattr (mqd_t __mqdes, stru ...
- VFS,super_block,inode,dentry—结构体图解
总结: VFS只存在于内存中,它在系统启动时被创建,系统关闭时注销. VFS的作用就是屏蔽各类文件系统的差异,给用户.应用程序.甚至Linux其他管理模块提供统一的接口集合. 管理VFS数据结构的组成 ...
- Jenkins的授权和访问控制
默认的Jenkins不包含任何的安全检查,任何人可以修改Jenkins设置,job和启动build等.显然地在大规模的公司需要多个部门一起协调工作的时候,没有任何安全检查会带来很多的问题. 在系统管理 ...