查询返回重复值

时间:2014-06-04 09:51:35

标签: mysql duplicates

数据库

id   name
1    suhana
2    nishantini
3    suhana
4    deepa
5    suhana

如何在字段名[name]中编写查询以获取输出

id name
1  suhana
3  suhana
5  suhana

1 个答案:

答案 0 :(得分:0)

试试这个:

select id, name from table_name where name in (SELECT name FROM table_name group by name having count(name) > 1)