当前位置: 代码迷 >> ASP.NET >> Aceess 查询语句有关问题
  详细解决方案

Aceess 查询语句有关问题

热度:4478   发布时间:2013-02-25 00:00:00.0
Aceess 查询语句问题
新闻表A

id title content  addtime

评论表B

id articleid conent username addtime

--------------------------------------

注意:B表中的articleid 对应A表中的id

目的:查询近一个月时间内评论做多的新闻所有信息及该条新闻的评论总数


access数据库

------解决方案--------------------------------------------------------
select * from 表A where id=(select top 1 articleid from 表B  group by articleid order by count(*) desc)
------解决方案--------------------------------------------------------
引用:
还缺个时间条件,
自然月:where datediff('w',addtime,now())=0
30天内:where dat……

写错了,第二个where条件应该是<30
------解决方案--------------------------------------------------------
select top 5 A.*,B.total from 表A as a left join (select articleid,Count(articleID) as total from 表B  group by articleid) as b on  a=id.b.articleid order by B.total desc
------解决方案--------------------------------------------------------
引用:
select top 5 A.*,B.total from 表A as a left join (select articleid,Count(articleID) as total from 表B  group by articleid) as b on  a=id.b.articleid order by B.total desc

等号位置是不是错啦,
on a.id=b.articleid
还有时间限制
where datediff('d',a.addtime,now())<30 
  相关解决方案