Home >Backend Development >PHP Tutorial >Solution to SQL Server SQL statement query for paginated data_PHP tutorial
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! ! ! !