select a.istop,a.name,a.body,a.username,count(b.ReplyID) as countID,a.[browse],b.replytime, b.replyperson 
from article a inner join reply b on a.Article=b.ArticleID order by a.istop desc,a.dateandtime desc

解决方案 »

  1.   

    取得这个主题的是否置顶(istop),作者(username),文章名(name),文章内容(body),被浏览次数(browse),这篇文章的回复数(即在reply数据库里的ArticleID字段和这个主题的ArticleID相同的数量),回复时间最晚的帖子的回复时间(reply.replytime)和回复人(reply.replyperson),以后当我按主题左边的"+"小图标时,所有回复的回复人,回复时间和回复主体都要显示出来,所以这也要取。置顶的在最上方,然后按时间早晚排列,最新的在最上方。具体执行结果看我提供的网址http://www.longre.com/bbs/list.asp?boardid=4 
    其中 article.boardid字段决定文章所属板块,在这个页面只取这个板块,即boardid=4的,就是说在where里再加一个条件
      

  2.   

    黄山光明顶兄弟: 我把数据从ascess放到sql中调试,出现以下错误提示:
    column'a.istop' is invalid in the select list because it is not contained in an aggregate function and there is no groutby clause
    如果把istop列删了,提示 column'a.name' is invalid.....
    如果后面加group by articleID,提示语法错误。加group by a.articleID也不行