博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[LeetCode] Delete Duplicate Emails
阅读量:4591 次
发布时间:2019-06-09

本文共 773 字,大约阅读时间需要 2 分钟。

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 belowDELETE P1 FROM Person P1, Person P2 WHERE P1.Id>P2.Id AND P1.Email=P2.Email;# 1223 ms

 

转载于:https://www.cnblogs.com/immjc/p/7722783.html

你可能感兴趣的文章
JSP简单功能介绍
查看>>
javaweb学习(四)——在tomcat服务器下创建web项目
查看>>
DWR应用—快速入门篇
查看>>
LOJ #2145. 「SHOI2017」分手是祝愿
查看>>
二分查找
查看>>
[导入]子网掩码和ip地址的关系
查看>>
Rehashing
查看>>
单点登录SSO:概述与示例
查看>>
暑假集训(3)第三弹 -----Til the Cows Come Home(Poj2387)
查看>>
SpringMVC工作原理及流程
查看>>
工具类封装
查看>>
从数据库的表导出到Excel表格中【让客户端下载的Excel】
查看>>
js5:框架的使用,使框架之间无痕连接
查看>>
第六次随笔
查看>>
jquery快速入门三
查看>>
分布式锁 原理及实现方式
查看>>
四则运算三完整版
查看>>
18.3 线程的声明周期
查看>>
fomo6d游戏系统开发 fomo6d游戏
查看>>
div简单布局理解
查看>>