日期:2014-05-16  浏览次数:20724 次

mysql,选择某字段出现次数大于1的记录
table:
a b c d
1 a a a
1 a b c
1 b c d
选择b字段相同记录出现次数大于1的sql语句怎么写?
结果应为
a b c d
1 a a a
1 a b c

------解决方案--------------------
select a.* from a inner join
(select b from a group by b having count(*)>=2) b
on a.b=b.b