当前位置:首页 » 编程语言 » accesssql语句分页
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

accesssql语句分页

发布时间: 2022-04-14 06:00:52

Ⅰ Access的sql查询分页语句是什么

分页查询就是 比如 数据库是 30条数据 你每次查询10条出来select to 10 * from 表 查询 10条 点 下一页的话就是 查询出 1到10的数据select to 20 * from 表 where id not in (select to 10 id from 表) 查询出 查询出 11到20的数据一次类推

Ⅱ 求一条SQL分页语句在ACCESS数据库使用

--我觉得应该这样。。。
selecttop"+PageIndex*PageSize+"*fromTableNamet1
wherenotexists(selecttop"+(PageIndex-1)*PageSize+"*fromTableNamet2wheret2.ID=t1.IDorderbyt2.IDdesc)
orderbyIDdesc

Ⅲ access怎样实现分页,我需要动态的删除数据,比如1000个学生,可以任意删除,然后仍能分页,用学生id应该不行吧

select top 8 * from 表 where ID not in (select top "+iSql*8+" ID from 表 where 1=1"+strTiao+")
8是一页要显示的条数

Ⅳ php对access 的 分页 sql语句

select top 每页数量 * from 表 where id >(select top 1 max(id) from (select top (页数-1)*每页数量 from 表 order by id,name)) 或
select top 每页数量 * from 表 where id <(此处根据顺序和逆序)

Ⅳ 200分求 access sql语句分页 结束后马上给分

以ASP为例,讲思路,其它语言类同.

intpage = request("page") '--> 当前页
pagesize = 20 '每页数
pagecount = conn.execute(select count(1) from temp)(0) '获得总页数
if intpage = "" then intpage = 1
if isnull(pagecount) then pagecount = 1

if intpage = 1 then
sql = "select top " &pagesize& " * from temp"
else
sql = "select top " & pagesize &" * from temp where id not in(select top "&(intpage-1) * pagesize&" id from temp order by ordernumber desc,id desc) order by ordernumber desc,id desc"
end if
rs.open sql,conn,1,1
...
只是实现思路.

Ⅵ access中left join和limit联合分页查询怎么写sql语句

选择a.studentname,a.zhengpic,b.getbookdate的BookInfo为B,BOOKTYPE的作为,a.id = b.studentid b.id = c.id作为一个从studentinfo,

Ⅶ Access数据库分页语句怎么写呢。

set rs2=server.createobject("adodb.recordset")
sqltext2 ="SELECT * FROM news order by id desc"
rs2.open sqltext2,conn,3,3

dim MaxPerPage
MaxPerPage=7
'取得页数,并判断用户输入的是否数字类型的数据,如不是将以第一页显示
dim text,checkpage
text="0123456789"
rs2.PageSize=MaxPerPage
for i=1 to len(request("page"))
checkpage=instr(1,text,mid(request("page"),i,1))
if checkpage=0 then
exit for
end if
next

If checkpage<>0 then
If NOT IsEmpty(request("page")) Then
CurrentPage=Cint(request("page"))
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > rs2.PageCount Then CurrentPage = rs2.PageCount
Else
CurrentPage= 1
End If
If not rs2.eof Then rs2.AbsolutePage = CurrentPage end if
Else
CurrentPage=1
End if

%>
<%if row_count mod 1=0 then%>
</font></td>
</tr>
<%end if %>
<%
i=i+1
if i >= MaxPerpage then exit do
rs2.MoveNext
row_count=row_count+1
Loop
end Sub
end if
call list %>
<tr>
<%If Rs2.recordcount > MaxPerPage then %>
<td height="47" colspan="4"><font color="#000000">
<%
Response.write "<br>"
call showpages

%>
<%end if %>
</font></td>

<%
sub showpages()%>
<div align="center"><font color=000000>
<%
If currentpage > 1 Then
response.write "<a href='news.asp?page="+cstr(1)+"&btype="+Cstr(btype)+"'>首页</a><font color='#FF0000'><b>>></b></font>"
Response.write "<a href='news.asp?page="+Cstr(currentpage-1)+"&btype="+Cstr(btype)+"'>前页</a><font color='#FF0000'><b>>></b></font>"
Else
Response.write "首页<font color='#FF0000'><b>>></b></font>"
Response.write "前页<font color='#FF0000'><b>>></b></font>"
End if

If currentpage < Rs2.PageCount Then
Response.write "<a href='news.asp?page="+Cstr(currentPage+1)+"&btype="+Cstr(btype)+"'>后页</a><font color='#FF0000'><b>>></b></font>"
Response.write "<a href='news.asp?page="+Cstr(Rs2.PageCount)+"&btype="+Cstr(btype)+"'>尾页</a>"
Else
Response.write "后页<font color='#FF0000'><b>>></b></font>"
Response.write "尾页 "
End if
Response.write "页次:" & "<font color=#FF0000><b>" & Cstr(CurrentPage) & "</b></font>" & "<font color='#000000'><b>/" & Cstr(rs2.pagecount) & "</b></font>"
Response.write "<font color=#FF0000><b>" & Cstr(MaxPerPage) & "</b></font>" & "条<b>/</b>页 " & "共" & "<font color=#FF0000><b>" & Cstr(Rs2.RecordCount) & "</b></font>" & "<font color='#000000'>条.</font>"

response.write "<BR>"
%>
</font> </div>
<%end sub%>

Ⅷ 求ACCESS数据库的分页查询SQL语句

in的效率太低,不能利用索引,建议使用:
select
top
每页数量
*
from

where
id
>(select
top
1
max(id)
from
(select
top
(页数-1)*每页数量
from

order
by
id,name))

select
top
每页数量
*
from

where
id
<(此处根据顺序和逆序)

Ⅸ Access数据库分页查询,效率sql语句

in的效率太低,不能利用索引,建议使用:
select top 每页数量 * from 表 where id >(select top 1 max(id) from (select top (页数-1)*每页数量 from 表 order by id,name)) 或
select top 每页数量 * from 表 where id <(此处根据顺序和逆序)

Ⅹ access 没有自动增长列怎么分页

原因很多.如果是远程数据库.可能是网速问题.如果是本地数据库.可以是SQL语句的问题..另外就是你使用的电脑问题.一千条数据在一个页面显示.内存要求还是很多的.至少512MB.看看SQL语是否能优化一下.

1.原理:ASP分页其实是将数据库中的记录分割成若干段“分屏显示”
,为什么叫“分屏显示”显示,因为其实显示的原始页面只有1页,通过控制数据库显示,来刷新页面的显示内容(可能一些朋友会误会为动态产生若干页面来显示,呵呵,我刚刚学的时候也是这样以为的)
2.用到的几个函数
rs.pagesize--->定义一页显示记录的条数
rs.recordcount--->统计记录总数
rs.pagecount---->统计总页数
这几个函数相信大家都很快就明白意识了,不过还有一个函数它的用法可能理解起来难一点
rs.absolutepage--->将数据库指针移动到当前页要显示的数据记录的第一条记录,比如有20条记录的一个数据库,我们分为10条记录显示一页,当你的页面为2时,通过使用rs.absolutepage将指针移动到第11条记录处,依次类推....
3.大家明白原理后我们开始来看一段分页的程序,其中的一些文件我就不一一详细讲解了,不明白的朋友可以先看

http://www.2yup.com/asp/forum/branch.asp?pid=55084&pn=5
--------------------------------------------------
<!--#include file=conn1.asp-->
<%
dim m,n
set rs=server.CreateObject("adodb.recordset")
sqlstr="select * from message order by time desc"
rs.open sqlstr,conn,3,3
rs.pagesize=10 '定义一页显示的记录数目
tatalrecord=rs.recordcount '获取记录总数目
tatalpages=rs.pagecount '获取分页的数目
rs.movefirst
----------------------------
nowpage=request("page") '用request获取当前页数,注意page是自己定义的变量并非函数
--------------------------
if nowpage&"x"="x" then '处理页码为空时的情况
nowpage=1
else
nowpage=cint(nowpage) '将页码转换成数字型
end if
--------------------------------
rs.absolutepage=nowpage '将指针移动到当前显示页的第一条记录
-------------------------------
%>
---------------------------------------------
<%
n=1
while not rs.eof and n<=rs.pagesize
response.Write(rs("user") & "<br>")
response.Write(rs("tt") & "<br>")
n=n+1
rs.movenext '显示页面的数据
wend
%>
-------------------------------------------
共:<%=tatalpages%>页 当前为:<%=nowpage%>页
<%if nowpage>1 then%>
<a href="fy.asp?page=<%=nowpage-1%>">上一页</a>
<%else%>
上一页
<%end if%>
<%for k=1 to tatalpages%>
<%if k<>nowpage then %>
<a href="fy.asp?page=<%=k%>"><%=k%></a>
<%else%>
<%=k%>
<%end if%>
<%next%>
<%if nowpage < tatalpages then%>
<a href="fy.asp?page=<%=nowpage+1%>">下一页</a>
<%else%>
下一页
<%end if%> '加上页码连接
<%if nowpage<>1 then%>
<a href="fy.asp?page=<%=1%>"> 首页</a>
<%else%>
首页
<%end if%>
<%if nowpage<>tatalpages then %>
<a href="fy.asp?page=<%=tatalpages%>">末页</a>
<%else%>
末页

还有就是:
<%on error resume next
set rs1=server.createobject("adodb.recordset")
sql="select * from cgal order by id desc"
rs1.open sql,Conn,1,1
if rs1.eof and rs.bof then
response.write"暂时没有内容"
err.clear
end if
rs1.pagesize=10
if request("pageno")<>"" then
pageno=cint(request("pageno"))
if pageno<1 then pageno=1
if pageno>rs1.pagecount then pageno=rs1.pagecount
else
pageno=1
end if
rs1.absolutepage=pageno
%>
<table width="640" border="0" cellpadding="0" cellspacing="0">
<tr> <td align="center" valign="top"><table width="95%" border="0" cellpadding="0" cellspacing="0" class="css004">
<tr>
<td><table width="100%" border="0" cellspacing="4" cellpadding="0">
<tr><%
for i=1 to rs1.pagesize
if rs1.bof or rs1.eof then exit for
%>

<td align="center"><a href="<%=rs1("link")%>" target="_blank"> ◆ <%=rs1("units")%></a></td>
<%
if i mod 7=0 then
response.Write("</tr><tr>")
end if
%><%
rs1.movenext()
Next
%>
</table>
<table width="100%" height="21" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="41%"><table width="100%" height="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td background="css/image1.gif"><img src="img/works/002.gif" width="17" height="10" /></td>
</tr>
</table></td>
<td width="59%"><div class="green-black">
<%pagenum=rs1.pagecount
pageno=1
if request.QueryString("pageno")<>"" then
pageno=cint(request.QueryString("pageno"))
end if
'显示数量设定
showpagenum=10
'上一页显示判断
if pageno>1 then
response.write "<span class=""disabled""> <a href='?pageno="&pageno-1&"'>< Prev</a></span> "
'response.end()
end if
if pagenum>showpagenum then
num_left=pageno-1
num_right=pagenum-pageno
if num_left>(showpagenum/2) then
if num_right<(showpagenum/2) then
page_left=pageno-(showpagenum-num_right)+1
page_right=pagenum
else
page_left=pageno-(showpagenum/2)
page_right=pageno+(showpagenum/2)
end if
else
page_left=1
page_right=pageno+(showpagenum-num_left)-1
end if
'前项输出
for P=page_left to pageno-1
response.write " <a href='?pageno="&p&"'>"&p&"</a> "
next
'当前项输出
response.write " <span class=""current"">"&pageno&"</span> "
'后项输出
for f=pageno+1 to page_right
response.write " <a href='?pageno="&f&"'>"&f&"</a> "
next
else
for i=1 to pagenum
if i=pageno then
response.write " <span class=""current"">"&i&"</span> "
'response.end()
else
response.write " <a href='?pageno="&i&"'>"&i&"</a> "
'response.end()
end if
next
end if
'最后一页判断
if pageno<pagenum then
response.write " <a href='?pageno="&pageno+1&"'>Next > </a> "
'response.end()
end if%></div></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>

自己修改代码内的数据库名和字段就OK了