zoukankan      html  css  js  c++  java
  • 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  | 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  |
    +----+------------------+
    
     
    DELETE p1
    FROM Person p1, Person p2
    WHERE p1.Email = p2.Email AND
    p1.Id > p2.Id
  • 相关阅读:
    Nancy 寄宿IIS
    原子操作
    CSRF跨站请求伪造
    CORS跨域
    C# 运算符
    Mysql 函数
    Mongodb for .Net Core 驱动的应用
    Mongodb for .Net Core 封装类库
    制作项目模板
    压缩图片
  • 原文地址:https://www.cnblogs.com/lovely7/p/5865495.html
Copyright © 2011-2022 走看看