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很多。
有問題再追問。