Differences between the paging query statements of Oracle, MySQL, and SqlServe databases: oraclesqlserve
First, define the parameters to be used in the paging statement:
Int currentPage; // current page
Int pageRecord; // number of records displayed per page
Take the ADDRESSBOOK data table as an example (10 records are displayed on each page ):
I. SqlServe paging statement for downloading
String SQL = "select top" + pageRecord + "* from addressbook where id not in (select top" + (currentPage-) * pageRecord + "id from t_user )"; // (currentPage-) * pageRecord: indicates the number of records starting from
Page 2 SQL Demo:
select top 20 * from addressbook where id not in (select top 10 id from addressbook)
Ii. MySQL database paging statements
String SQL = "select * from addressbook where limit" + (currentPage-) * pageRecord + "," + pageRecord + ""; // select * from table name [condition] limit M, N; // M indicates the number of records starting from, for example, each page displays a record, on the second page, you must start from the record. // N: the number of data records read on each page.
Page 2 SQL Demo:
select * from addressbook where limit 10,10
Iii. Oracle Database paging statements
String sqls = "select * from ( select rownum rn,t.* from addressbook t where rownum <= "+currentPage*pageRecord+" ) where rownum > "+(currentPage -1)*pageRecord;
Page 2 SQL Demo:
select * from ( select rownum rn,t.* from addressbook where rownum<= 20 ) where rownum > 10
The above section describes the differences between the paging query statements of Oracle, MySQL, and SqlServe databases. I hope this will help you!