首页 > 解决方案 > 在mysql中成对查找重复项

问题描述

我想知道如何在两列组合的表中找到重复值。

假设我的表的字段为id || name || father_name || region || dob

现在我怎样才能找到结果集,例如:

在此处输入图像描述

.ie 我想找到三列相同的所有行。

标签: mysql

解决方案


select t1.*
from your_table t1
join
(
    select name, father_name, region
    from your_table
    group by name, father_name, region
    having count(*) >= 3
) t2 on t1.name = t2.name 
    and t1.father_name = t2.father_name
    and t1.region = t2.region 

推荐阅读