新闻表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条件应该是<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
------解决方案--------------------------------------------------------
等号位置是不是错啦,
on a.id=b.articleid
还有时间限制
where datediff('d',a.addtime,now())<30