日期:2014-05-18 浏览次数:20470 次
select name from student group by name having count(*) > 1
------解决方案--------------------
select * from student t where exists (select 1 from student where name = t.name and id <> t.id)
------解决方案--------------------
select name from student group by name having max(id) > min(id)
------解决方案--------------------
select name from student group by name having count(1) > 1
select * from student where name in (select name from student group by name having count(1) > 1)
------解决方案--------------------
select name ,num from
(select name,num = count(name) from tb group by name)t where num >1
------解决方案--------------------
select * from student A where EXISTS (select name from student WHERE A.name = name group by name having count(1) > 1)
------解决方案--------------------
AcHerat 的性能发面比较好,建议采用这个
------解决方案--------------------
select name from student group by name having count(*) > 1
having count(*)>是对group by 后生成的虚拟表的数据进行过滤,过滤掉只有一个的情况,剩下的就是需要查询的了