196. Delete Duplicate Emails

原创 2016年08月29日 22:46:41

Write a SQL query to delete all duplicate email entriesin 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 thistable.

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

+----+------------------+

| Id | Email            |

+----+------------------+

| 1 | john@example.com |

| 2 | bob@example.com  |

+----+------------------+


DELETE a
FROM Person a, Person b
WHERE a.Id>b.Id AND a.Email=b.Email;




版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

leetcode 196. Delete Duplicate Emails

196. Delete Duplicate Emails   Question Editorial Solution  My Submissions To...

leetcode 196. Delete Duplicate Emails delete

题意:删除Email重复的行,保留Id最小的行,也就使每个Email只保留Id最小那个 思路:用删除语句进行删除 题目链接:https://leetcode.com/problem...

[MySQL]LeetCode196 Delete Duplicate Emails

删除重复列,只保留Id最小的一行
  • fumier
  • fumier
  • 2015年07月28日 20:44
  • 1008

LeetCode196. Delete Duplicate Emails

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

Delete Duplicate Emails

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

【Leetcode Database】Delete Duplicate Emails

题目: Write a SQL query to delete all duplicate email entries in a table named Person, keeping on...

LeetCode OJ Duplicate Emails

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

Delete Duplicate Files

  • 2012年09月06日 16:54
  • 239KB
  • 下载

How to delete duplicate rows with SQL

from: http://www.xaprb.com/blog/2006/10/11/how-to-delete-duplicate-rows-with-sql/ The comments on m...
  • nomad2
  • nomad2
  • 2012年03月25日 18:31
  • 688

delete duplicate rows in a table

Purpose:========The purpose of this article is to provide you with an example of how to delete dupli...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:196. Delete Duplicate Emails
举报原因:
原因补充:

(最多只允许输入30个字)