Home  >  Article  >  Backend Development  >  Solution to SQL Server SQL statement query for paginated data_PHP tutorial

Solution to SQL Server SQL statement query for paginated data_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:00:291147browse

For example: it is required to select the record on page 3000 in tbllendlist, with 100 records on each page.
----------
Method 1:
----------
select top 100 * from tbllendlist
where fldserialNo not in
(
select top 300100 fldserialNo from tbllendlist
order by fldserialNo
)
order by fldserialNo
----------
Method 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
Method 1 executes faster!
However, this approach is still very troublesome. I strongly look forward to Microsoft inventing a new paging SQL statement! ! ! !


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631234.htmlTechArticleFor example: it is required to select the record on page 3000 in tbllendlist, with 100 records on each page. ---------- Method 1: ---------- select top 100 * from tbllendlist where fldserialNo not in ( se...
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