Oracle, MYSQL, sqlserver, and DB2 paging queries DB2: www.2cto.com DB2 paging queries SELECT * FROM (Select Field 1, Field 2, Field 3, rownumber () over (ASC Column Used for order by sorting) AS rn from Table Name) AS a1 WHERE a1.rn BETWEEN 10 AND 20 or above indicates extracting the record from 10th to 20 select * from (select rownumber () over (order by id asc) as rowid from table where rowid <= endIndex) where rowid> startIndex if the Order By field has duplicate values, make sure to put this field in over () select * from (select ROW_NUMBER () OVER (order by DOC_UUID DESC) as rownum, DOC_UUID, DOC_DISPATCHORG, DOC_SIGNER, DOC_TITLE from DT_DOCUMENT) a where ROWNUM> 20 and ROWNUM <= 30 Add the row number, not sort select * from (select ROW_NUMBER () OVER () as rownum, t. * from DT_DOCUMENT t) a adds a row number and sorts BY column select * from (select ROW_NUMBER () OVER (order by DOC_UUID DESC) as rownum, t. * from DT_DOCUMENT t) a Mysql: the simplest select * from table limit start, pageNum, for example, getting 20 data from 10 select * from table limit 10, 20 Oracle: www.2cto.com select * from (select rownum, name from table where rownum <= endIndex) where rownum> startIndex example from table Sys_option (primary key is sys_id) the statement is as follows: SELECT * FROM (select rownum r, t1. * From Sys_option where rownum <30) t2 Where t2.R> = 10 SQL server: for example, to retrieve 10 or 20 records FROM the table Sys_option (primary key: sys_id), the statement is as follows: SELECT * From (select rownum r, t1. * FROM Sys_option where rownum <30) t2 Where t2.R> = 10