这条查询语句有问题,只能显示500条以内的数据(不管新的还是旧的)超过500后新的数据就不显示了,Sql="Select * from (select top 1000 isbest,istop,logid,postid,topic,author,replys,lastupdate From oblog_teampost Where teamid=" & Group_id & " And iDepth=0 And isTop=1 " & SqlPart & " Order By Lastupdate Desc"
Sql= Sql & " union " Sql= Sql & " Select top 1000 isbest,istop,logid,postid,topic,author,replys,lastupdate From oblog_teampost Where teamid=" & Group_id & " And iDepth=0 And isTop=0 " & SqlPart & " Order by Lastupdate desc ) DERIVEDTBL ORDER BY istop DESC , lastupdate DESC"
怎么修改才能显示最新的500条记录(按lastupdate)
Sql= Sql & " union " Sql= Sql & " Select top 1000 isbest,istop,logid,postid,topic,author,replys,lastupdate From oblog_teampost Where teamid=" & Group_id & " And iDepth=0 And isTop=0 " & SqlPart & " Order by Lastupdate desc ) DERIVEDTBL ORDER BY istop DESC , lastupdate DESC"
怎么修改才能显示最新的500条记录(按lastupdate)
这样会返回2000条记录吧?
" & SqlPart & "的内容是什么?
(
select top 500 isbest,istop,logid,postid,topic,author,replys,lastupdate
From oblog_teampost Where teamid=Group_id And iDepth=0 And isTop=1 Order By Lastupdate Desc
) DERIVEDTBL
ORDER BY istop DESC , lastupdate DESC
Sql= Sql & " union "Sql= Sql & " Select top 500 isbest,istop,logid,postid,topic,author,replys,lastupdate From oblog_teampost Where teamid=" & Group_id & " And iDepth=0 And isTop=0 " & SqlPart & " Order by Lastupdate desc ) DERIVEDTBL ORDER BY istop DESC , lastupdate DESC"
建议你把union 改为union all,这样两个结果集组合的时候就不会合并相同的记录了以上修改之后,你的语句会选出来2000条记录 如果你要对此加以限制,可以在最外层的'select * '变成'select top 500 *'