<%@language="
vbscript" codepage="936"%>
<%
'分頁sql語句生成**
function getpagesql(tblname,fldname,pagesize,pageindex,ordertype,strwhere)
dim strtemp,strsql,strorder
'根據排序方式生成相關**
if ordertype=0 then
strtemp=">(select max([" & fldname & "])"
strorder=" order by [" & fldname & "] asc"
else
strtemp="<(select min([" & fldname & "])"
strorder=" order by [" & fldname & "] desc"
end if
'若是第1頁則無須複雜的語句
if pageindex=1 then
strtemp=""
if strwhere<>"" then
strtmp = " where " + strwhere
end if
strsql = "select top " & pagesize & " * from [" & tblname & "]" & strtmp & strorder
else '若不是第1頁,構造sql語句
strsql="select top " & pagesize & " * from [" & tblname & "] where [" & fldname & "]" & strtemp & _
" from (select top " & (pageindex-1)*pagesize & " [" & fldname & "] from [" & tblname & "]"
if strwhere<>"" then
strsql=strsql & " where " & strwhere
end if
strsql=strsql & strorder & ") as tbltemp)"
if strwhere<>"" then
strsql=strsql & " and " & strwhere
end if
strsql=strsql & strorder
end if
getpagesql=strsql '返回sql語句
end function
response.write(getpagesql("message","messageid",10,1,0,""))
%>
海量資料的分頁
第一種方法 declare pagesize int,currpage int,topnum int,previous int select pagesize 30 select currpage 2 select topnum currpage pagesize select previous c...
海量資料分頁查詢
select top 25 id,registerid,filenameid,createtime from tbfilenamerecord where id select min id from select top 100 id from tbfilenamerecord where regi...
mysql 通用儲存過程分頁 海量資料分頁
老話題了,不多說了看 吧 測試表create table if not exists test id int 11 not null auto increment,sort int 11 title varchar 50 primary key id engine innodb default ch...