各类数据库分页共享

各类数据库分页共享

MSSQL:

select * from (   select TOP size * FROM ( SELECT TOP (start*size)   * from table_name ORDER BY BY id ASC ) as aSysTable   ORDER BY id DESC ) as bSysTable ORDER BY id ASC

size:每次获取的记录数

start:请求的页数

MySQL(SQLLite分页也和MySQL一样):

select * from table_name limit start,pageNum

start:取数据的定位点 [开始是从0开始]
pageNum:每次取多少

比如:start=0|ageNum=5
那么就是说,取1-6 条数据

Oracle:

SELECT *   FROM (SELECT a.*, ROWNUM row_num FROM (   table_name   ) a) b   

WHERE b.row_num BETWEEN 1 AND 3  

这是取table_name第一到第三条记录

你可能感兴趣的:(各类数据库分页共享)