當前位置:首頁 > 建站常識 > 列表

sql利用(yòng)ID大(dà)于多(duō)少和(hé)SELECT TOP分(fēn)頁

點擊:時(shí)間:2017/8/13關鍵詞:上海網頁設計 上海網站建設安全 asp程序
sql分(fēn)頁:利用(yòng)ID大(dà)于多(duō)少和(hé)SELECT TOP分(fēn)頁程序代碼部分(fēn):SELECT TOP 頁大(dà)小 * FROM TestTable WHERE (ID > (SELECT MAX(id) FROM (SELECT TOP 頁大(dà)小*頁數 id FROM
sql利用(yòng)ID大(dà)于多(duō)少和(hé)SELECT TOP分(fēn)頁
sql分(fēn)頁:利用(yòng)ID大(dà)于多(duō)少和(hé)SELECT TOP分(fēn)頁
 程序代碼部分(fēn):

SELECT TOP 頁大(dà)小 *  

FROM TestTable  

WHERE (ID > (SELECT MAX(id) FROM (SELECT TOP 頁大(dà)小*頁數 id FROM 表 ORDER BY id) AS T))  

ORDER BY ID

ASP超高(gāo)效分(fēn)頁算(suàn)法<%'每頁的(de)記錄數dim pagesizepagesize= "30" '讀出總記錄數,總頁數Dim TotalRecords,TotalPagesSQLstr="Select count(id) As RecordSum From table1"Set Rs=conn.Execute(SQLstr,0,1) TotalRecords=Rs("RecordSum") if Int(TotalRecords/pagesize)=TotalRecords/pagesize thenTotalPages=TotalRecords/pagesizeelseTotalPages=Int(TotalRecords/pagesize)+1end ifRs.Close Set Rs=Nothing '當前頁碼dim pagepage=Request("page")if isnumeric(page)=false thenresponse.write "<SCRIPT language=JavaScript>alert('參數錯誤!');"response.write "window.close();</SCRIPT>"response.endend ifIf page="" or page<1 Then page=1If page-TotalPages>0 Then page=TotalPagespage=int(page)if page=1 thensql="select top "&pagesize&" id,title,time from table1 order by time desc"elsesql="select top "&pagesize&" id,title,time from table1 where time<(SELECT Min(time) FROM (SELECT TOP "&pagesize*(page-1)&" time FROM table1 ORDER BY time desc) AS T) order by time desc"end ifSet rs = Server.CreateObject ("ADODB.Recordset")rs.Open sql,conn,1,1Do While Not rs.Eofresponse.write "每條記錄信息:"&rs("id")&"<br>"rs.movenextlooprs.closeset rs=nothing''翻頁代碼省略……%> 
預約建站
免費提供網站優化(huà)
領取關鍵詞