sql语句分页查询
‘壹’ sql语句分页详解
这就是一个简单的查询语句,一个语句分为select 与 from 之间的部分,from 与 where之间的部分 和where 后边条件部分。
from 后跟的是表,
你说的a,b就是表名。只不过 是把(select top 20 主键字段,排序字段 from 表名 order by 排序字段 desc)查询的结果作为表a了。
‘贰’ sql 分页查询 数据库高手请进
请楼主在前台语言中实现。
‘叁’ sql分页语句查询问题
从t1结果集中取数据的时候没有排序,当然结果不会变
改成这样
select * from(select top 3 * from(select top 3 * from student order by 编号 desc) t1 order by 编号 desc) t2 order by 编号 asc
‘肆’ 关于分页查询的sql语句
这里的K不仅仅是个别名的作用,他把 (select *,row_number() over(order BY UserID) rowIndex from userinfo)做为一个表来查询 ,如果不加则作为一个查询结果集,SQL无法再查询结果集上在进行查询
‘伍’ 如何用sql语句 实现分页查询
适用于 SQL Server 2000/2005
SELECT TOP 页大小 *
FROM table1
WHERE id NOT IN
SELECT TOP 页大小*(页数-1) id FROM table1 ORDER BY id
‘陆’ sql语句查询并且加分页
你的意思是前五行是固定的,后十行进行分页是么,前五行固定写死,后十行用参数或动态sql来进行分页。例如第一页:
select top 5 id,readcount,weight from table1 order by readcount desc
union all
select top 10,id,readcount,weight from table1 order by weight desc --这句进行动态sql或传参数进行分页,网上分页的sql很多。有问题再追问。
‘柒’ sql 分页多条件查询
查询可以用if else 去做。
例如:
sql="select * from ........."
``````````````
xh=request("型号")
······
if xh<>"" then sql=sql+" and 型号='"&xh&"'"
分页可以用
<%TurnPage(rs,20,"型号="&xh&"&其他6个参数·······")%>
<%
Sub TurnPage(ByRef Rs_tmp,PageSize,canshu) 'Rs_tmp 记录集 PageSize 每页显示的记录条数;
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordCount '总记录条数
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
'直接输入页数跳转;
If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
'如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If
'获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
'取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
response.write "<table border=0 width='100%'><tr> "
If RecordCount = 0 or TotalPage = 1 Then
Response.Write ""
Else
response.write "<td align=left style='font-size:12px'> 总页数:<font color=#ff3333>"&TotalPage&"</font>页"
response.write "当前第<font color=#ff3333>"&PageNo&"</font>页 </td> "
response.write "<td align='right' style='font-size:12px'> "
end if
If RecordCount = 0 or TotalPage = 1 Then
Response.Write ""
Else
response.write "<a href='"&fileName&"?PageNo=1&"&canshu&"'>首页|</a>"
If PageNo - 1 = 0 Then
Response.Write "前页|"
Else
response.write "<a href='"&fileName&"?PageNo="&PageNo-1&"&"&canshu&"'>前页|</a>"
End If
If PageNo+1 > TotalPage Then
Response.Write "后页|"
Else
response.write "<a href='"&fileName&"?PageNo="&PageNo+1&"&"&canshu&"'>后页|</a>"
End If
response.write "<a href='"&fileName&"?PageNo="&TotalPage&"&"&canshu&"'>末页</a>"
End If
response.write "</td></td></tr></table> "
end sub%>
‘捌’ sql语句查询加分页
你的意思是前五行是固定的,后十行进行分页是么,前五行固定写死,后十行用参数或动态sql来进行分页。例如第一页:
selecttop5id,readcount,
unionall
selecttop10,id,readcount,--这句进行动态sql或传参数进行分页,网上分页的sql很多。
有问题再追问。