【问题标题】:Suppose multiple column with 1000 records in a table, how to find the duplicate record in whole table? [duplicate]假设一个表中有多个列有 1000 条记录,如何在整个表中查找重复记录? [复制]
【发布时间】:2017-08-13 00:27:09
【问题描述】:

假设一个表有多列有1000条记录,如何查找整个表中的重复记录?

请帮忙。

【问题讨论】:

  • 您使用的是 MySQL 还是 Oracle?不要标记未涉及的产品。
  • 做一个 GROUP BY,使用 HAVING 和 count() > 1。

标签: mysql sql oracle duplicates


【解决方案1】:

重复的 ID:

select s.id, t.* 
from [stuff] s
join (
    select name, city, count(*) as qty
    from [stuff]
    group by name, city
    having count(*) > 1
) t on s.name = t.name and s.city = t.city     

答案也发布在此主题中:How do I find duplicates across multiple columns?

【讨论】:

    猜你喜欢
    • 2012-10-15
    • 2020-07-06
    • 1970-01-01
    • 2016-06-14
    • 1970-01-01
    • 2013-06-09
    • 2017-11-13
    • 2010-10-18
    • 1970-01-01
    相关资源
    最近更新 更多