时间:2021-07-01 10:21:17 帮助过:35人阅读
access分页 技术 思想 A: 程序代码 select top 分页数 * from 表 where 主键 not in (select top 第几页*分页数 主键 from 表 where 过滤条件) ACCESS分页 技术 思想 B: 程序代码 select top 页大小 * from 表1 where 主键 (select min(主键) from (select
access分页技术思想A:
程序代码
select top 分页数 * from 表 where 主键 not in (select top 第几页*分页数 主键 from 表 where 过滤条件)
ACCESS分页技术思想B:
程序代码
select top 页大小 * from 表1 where 主键 <(select min(主键) from (select top 页大小 主键 from 表1 order by 主键 desc) as tblTmp) order by 主键 desc
相比这两种设计思想,就大容量的数据而言,譬如一表几万条数据的显示的时候,就能明显的感觉出,前者比后者快了,因为前者不用建立后台临时表处理!,少了一个环节!不过简单的说,还是很容易理解的
打个比方,我一页要五行数据,现在是第三页,那么第几页应该等于需要要的页数乘以记录!
一个基于此思路的分页函数应用:
程序代码
<%
Function ShowClass(page, Fcount, order, desc)
if page = "" or len(page) = 0 then page = 1
SkinStr = ""
pageStr = ""
SkinTatol = conn.execute("select count(*) from Skin")(0)
Filtwheres = "order by "&order" "&desc
if page > 1 then
SkinSQL = "select top "& Fcount " Skin_ID,Skin_Name,Skin_Designer,Skin_PubDate,Skin_DesignerURL,Skin_DesignerMail,Skin_Geterip,Skin_GetTime,LocalSkinInfoPReview,Skin_RandromNumber,Skin_DownCouns,Skin_FromURL from Skin where Skin_ID not in (select top "& ((page -1)* Fcount)" Skin_ID from Skin "&Filtwheres") " & Filtwheres
else
SkinSQL = "select top "& Fcount " Skin_ID,Skin_Name,Skin_Designer,Skin_PubDate,Skin_DesignerURL,Skin_DesignerMail,Skin_GeterIP,Skin_GetTime,LocalSkinInfoPreview,Skin_RandromNumber,Skin_DownCouns,Skin_FromURL from Skin " & Filtwheres
end if
'------------------ www.knowsky.com 分页栏 ---------------------
total = SkinTatol '取总数
per = Fcount '每页显示条数
pages = total / per '总共的页数
If pages <> int(pages) then
pages = int(pages) + 1
Else
pages = pages
End If
If (page * per) >= total then
bn = total
Else
bn = page * per
End If
if pages <= 9 then
if page > 5 then
a = page - 4
b = page + 4
if b > pages then b = pages
else
a = 1
b = pages
end if
else
if page > 5 then
a = page - 4
b = page + 4
if b > pages then b = pages
else
a = 1
b = 9
end if
end if
'------------- start --------------------
pageStr = pageStr & "
< | "" & i & " | "" & i & " | "> | "
| " & Bright