Home  >  Article  >  php教程  >  关于SQL Server SQL语句查询分页数据的解决方案

关于SQL Server SQL语句查询分页数据的解决方案

WBOY
WBOYOriginal
2016-06-13 10:04:421173browse

比如:要求选取 tbllendlist 中 第3000页的记录,每一页100条记录。
----------
方法1:
----------
select top 100 * from tbllendlist
where fldserialNo not in
(
select top 300100 fldserialNo from tbllendlist
order by fldserialNo
)
order by fldserialNo
----------
方法2:
----------
SELECT TOP 100 *
FROM tbllendlist
WHERE (fldserialNo >
(SELECT MAX(fldserialNo)
FROM (SELECT TOP 300100 fldserialNo
FROM tbllendlist
ORDER BY fldserialNo) AS T))
ORDER BY fldserialNo
方法1执行速度比较快!
不过,这种做法还是很麻烦,强烈期待微软发明新的可分页的SQL语句来!!!!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn