以后地位:首页 > 建站常识 > 列表

sql操纵ID大于几多和SELECT TOP分页

点击: 次时候:2017/8/13关头词:上海网页设想 上海网站扶植宁静 asp法式
sql分页:操纵ID大于几多和SELECT TOP分页法式代码局部:SELECT TOP 页巨细 * FROM TestTable WHERE (ID > (SELECT MAX(id) FROM (SELECT TOP 页巨细*页数 id FROM
sql操纵ID大于几多和SELECT TOP分页
sql分页:操纵ID大于几多和SELECT TOP分页
 法式代码局部:

SELECT TOP 页巨细 *  

FROM TestTable  

WHERE (ID > (SELECT MAX(id) FROM (SELECT TOP 页巨细*页数 id FROM 表 ORDER BY id) AS T))  

ORDER BY ID

ASP超高效分页算法<%'每页的记实数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''翻页代码省略……%> 

预定建站
收费供给网站优化
支付关头词