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;

LeetCode - Delete Duplicate Emails的更多相关文章

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

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  2. LeetCode——Delete Duplicate Emails(巧用mysql临时表)

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  3. Leetcode 182. Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  4. LeetCode Database: Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  5. leetcode【sql】 Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  6. LeetCode DB : Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  7. leetcode 196. Delete Duplicate Emails 配合查询的delete

    https://leetcode.com/problems/delete-duplicate-emails/description/ 题意要对原来的数据表进行删除,不删除不行,它每次只输出原来那个表. ...

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

    题目标签: 题目给了我们一个 email 的表格,让我们删除重复的. 建立Person p1,Person p2,当email 相同时,而且 p1 id 要大于 p2 id 时候,删除这一行. Jav ...

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

随机推荐

  1. PHP无限极分类 - 3 - 分类目录

    结合zui---Tree组件,实现分类目录. 目录结构同上一篇: 效果: 代码: <!DOCTYPE html> <html lang="en"> < ...

  2. 用Jquery获取checkbox多个选项

    1,下拉框: var cc1   = $(".formc select[@name='country'] option[@selected]").text(); //得到下拉菜单的 ...

  3. AWS SDK for C++调用第三方S3 API

    这里介绍AWS SDK for C++ 1.0.x版本,比如下载: https://github.com/aws/aws-sdk-cpp/archive/1.0.164.tar.gz 环境:RHEL/ ...

  4. selenium测试(Java)--截图(十九)

    package com.test.screenshot; import java.io.File; import java.io.IOException; import org.apache.comm ...

  5. 指定Android Studio编译工程时的源文件编码

    统一设置为UTF8编码在工程的根目录下的build.gradle文件中,添加定义.tasks. withType(JavaCompile) {    options.encoding = " ...

  6. ftp传输出现问题

    将文件打包压缩之后,从ftp服务器下载到本地,进行解压,出现下面的问题. 原来是传输文件的时候是默认按照netascii的格式进行传输的,没有按照二进制文件的形式传输. 再传输之前,使用bin指定传输 ...

  7. AMD和RequireJS初识----优化Web应用前端(按需动态加载JS)

    RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的RequireJS压缩后只有14K,堪称非常轻量.它还同时可以和其他的框架协同工作,使用Re ...

  8. jvm载入过程

    类载入过程 类从被载入到虚拟机内存中開始,到卸载出内存为止,它的整个生命周期包含:载入.验证.准备.解析.初始化.使用和卸载七个阶段.它们開始的顺序例如以下图所看到的: 当中类载入的过程包含了载入.验 ...

  9. Jquery实现选项卡功能

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. uniqid,md5,microtime

    <?php header("content-type:text/html;charset=utf-8"); $str = uniqid(md5(microtime(true) ...