显示mysql中特定列的所有重复值

时间:2017-01-05 08:00:16

标签: mysql

id name phone
1     google 5689
2       msn  63699
3       google 78972
4       yahoo  20144

我想像这样显示结果

id name phone
1     google 5689
3       google 78972

2 个答案:

答案 0 :(得分:0)

您可以使用子查询执行此操作:

select t.*
from yourtable t
inner join (
    select name
    from yourtable
    group by name
    having count(id) > 1
) t1 on t.name = t1.name

答案 1 :(得分:0)

select *
from ax
where name1 in (select name1 from ax group by name1 having count(name1)>1)