日期:2014-05-17  浏览次数:20908 次

请教一个sql语句,任何查询出一个表中所有标题有重复的数据来
如题,
access数据库
表info      
字段id,title,content

比如表中有几条数据如下
id       title             content
1         咖啡               咖啡是好东西
2         电脑               电脑发展真快
3         咖啡               咖啡可以提神的
4         网络               网络可以让人方便,也可以让人变坏
5         电脑               好点的电脑怎么也得2,3万元人民币吧!
6         csdn               csdn里面有人能帮你回答问题,不错,我喜欢!


怎么写sql语句将上面的title一样的数据提取出来,如:
id       title             content
1         咖啡               咖啡是好东西
2         电脑               电脑发展真快
3         咖啡               咖啡可以提神的
5         电脑               好点的电脑怎么也得2,3万元人民币吧!


谢谢,回答正确马上结帖给分!!!

------解决方案--------------------
select distinct title from tablename
------解决方案--------------------
关注....
------解决方案--------------------
晕给反了。
select title from tablename group by title having count(title)> 2
------解决方案--------------------
select title from tablename group by title having count(title)> 1
大于1就可以了。
------解决方案--------------------
select * from title Where title in(select title from tablename group by title having count(title)> 1)
------解决方案--------------------
wgybb(中原狼卒)
------解决方案--------------------

------解决方案--------------------
id title content
1 咖啡 咖啡是好东西
2 电脑 电脑发展真快
3 咖啡 咖啡可以提神的
5 电脑 好点的电脑怎么也得2,3万元人民币吧!

你如是这样显示的话,就用
select * from tblName Where title in(select title from tablename group by title having count(title)> 1)

如果只显示Title字段的话就用
select title from tablename group by title having count(title)> 1