1. mssql
Use two TOP commands to obtain the paging data we want, for example:
Select * from
(
Select top (
PageSize
) * From
(
Select top (
PageSize
*
PageIndex
)*
From articles
Order by pubtime DESC
)
Order by pubtime ASC
)
Order by pubtime DESC 2, Oracle
For Oracle databases, there are several differences that seriously impede the implementation of the above methods. For example, Oracle does not support the TOP Keyword: however, this does not seem very serious, because it provides the rownum implicit cursor, it can implement features similar to TOP, such:
Select top 10... from where...
To write
Select... from... where... and rownum <= 10
Rownum is the record number (1, 2, 3 ...), however, there is one troublesome thing: if the SQL statement contains ORDER... in sorting, rownum is actually sorted by "Number" first! In this way, this serial number is not applicable if it is not processed.
It can be divided into the following pages: (number Ora1)
Select * from
(
Select a. *, rownum R
From
(
SELECT *
FROM Articles
Order by PubTime DESC
, ArticleID -- // Add one or more fields (such as primary key fields,
ROWID) to make the sorting result unique
)
WHERE rownum <= PageUpperBound
) B
WHERE r> PageLowerBound;
The blue part can be changed to any SQL SELECT statement, which is convenient.
PS: Oracle
Of
Rownum
Not Supported
>,>=, =, Between... and
, Can only use the above symbols
(<
,
<=
,
! =)