3 Ways to paging SQL Server are as follows:
---SQL Server 2005-page statement collection
----Disadvantages:
Top: Complex SQL must be written by the user and no composite primary key is supported
Max: Users must write complex SQL and do not support non-unique column sorting
--row: sqlserver2000 not supported
--------------------------------
Id,email,qq,wechart,phone,phone1 Select Top @pagesize
The Where ID isn't in
(SELECT Top (@pagesize * (CURRENTPAGE-1)) ID from contacts order by ID ASC)
Ten ORDER by ID ASC
11
12
13-The least efficient paging statement (you only need to know the number of pages and how many per page to display)
SELECT * from Aisino_bd_telephonerecord the ORDER by ID ASC;
Select Top 5 ID for Companyid,projectid from dbo. Aisino_bd_telephonerecord
The Where ID not in (
Select Top (5* (2-1)) ID from Aisino_bd_telephonerecord ORDER by ID ASC
by ID ASC
19
20
----------------------
The second way, you need to know how many pages and the number of pages per page can be-------------------------------
22
Select Top 5 * from Aisino_bd_telephonerecord
Where Id> (
Select Max (ID)
From (select Top (5* (2-1)) ID to Aisino_bd_telephonerecord ORDER by ID ASC) TT
27)
ORDER BY ID ASC
29
30
------------------
-the third method---only need to know the number of pages and how many pages per page can be displayed----------------------------------
32
33
SELECT *
From (select Top (5* (1-1) +5) row_number () over (order by Id ASC) __rn__, * from Aisino_bd_telephonerecord) t
where __rn__>5* (1-1)
Pagination in Oracle:
Oracle has its own rownum, directly using rownum for paging:
1
SELECT *
2
From (select A.*, rownum NM
3
From (SELECT * from Aos_rms_user) a
4
where RowNum <= 5* (1-1) # +5)
5
where nm >= 5* (1-1)