日期:2014-05-18 浏览次数:20422 次
SELECT top 1 wb_bbsReply.replyTime, wb_bbsReply.postId, wb_bbsPost.postTitle FROM wb_bbsReply INNER JOIN wb_bbsPost ON wb_bbsReply.postId = wb_bbsPost.postId where wb_bbsReply.userId=@userid order by wb_bbsReply.replyTime desc
------解决方案--------------------
SELECT min(wb_bbsReply.replyTime), min(wb_bbsReply.postId), wb_bbsPost.postTitle FROM wb_bbsReply INNER JOIN wb_bbsPost ON wb_bbsReply.postId = wb_bbsPost.postId where wb_bbsReply.userId=@userid group by wb_bbsPost.postTitle
------解决方案--------------------
wb_bbsReply 是一个贴子回复表?
wb_bbsPost 是BBS的贴子列表?
如果是就可以这样试试
Select wb_bbsPost.postTitle, replyTime=(select top 1 replyTime From wb_bbsReply Where wb_bbsReply.postId = wb_bbsPost.postId Order By wb_bbsReply.repluTime Desc ), wb_bbsPost.postId From wb_bbsPost Where exists (Select * From wb_bbsReply Where wb_bbsReply.postId = wb_bbsPost.postId and wb_bbsReply.userId=@userid )