DB2数据库分页: (DB2数据库相关知识:http://www.db2china.net)
/**增加行号, 附带字段排序(over()方法对“TEMP_ID”字段排序)*/
select * from (
select row_number() over( order by TEMP_ID desc ) as rownum, T.* from SMS_TEMPLATE T
) as t
where t.rownum> 0 and t.rownum<=10
/**增加行号, 无排序*/
select * from (
select row_number() over() as rownum, T.* from SMS_TEMPLATE T
) as t
where t.rownum> 0 and t.rownum<=10
/**无行号,附带字段排序*/
select * from SMS_TEMPLATE order by TEMP_ID fetch first 10 rows only
/**无行号,无排序*/
select * from SMS_TEMPLATE fetch first 10 rows only
分页sql:(条件查询每页10条数据)
默认第1页或者首页查询sql:
select * from SMS_TEMPLATE fetch first 10 rows only
非首页查询sql:
select * from SMS_TEMPLATE where TEMP_ID not in (
select TEMP_ID from SMS_TEMPLATE order by TEMP_ID fetch first (PageIndex-1)*10 rows only
) ORDER BY TEMP_ID fetch first 5 rows only
MySql数据库分页:
语法:(关键字 limit) 注意不包含startIndex坐标
select * from 表名 order by 字段 limit startIndex , endIndex
分页sql:(条件查询每页10条数据)
默认第1页或者首页查询sql:
select * from SMS_TEMPLATE order byTEMP_ID limit 0 , 10
非首页查询sql:
select * from SMS_TEMPLATE order byTEMP_ID limit (PageIndex-1)*10 , (PageIndex)*10
Oracle数据库分页:
/**增加行号, 无排序*/
select * from (select rownum, * from SMS_TEMPLATE where rownum <= endIndex ) where rownum > startIndex
默认第1页或者首页查询sql:
select * from (select rownum, * from SMS_TEMPLATE) where rownum <= 10
非首页查询sql:
select *from (select rownum, * from SMS_TEMPLATE
where rownum <= (PageIndex)*10) where rownum > (PageIndex-1)*10
SQLServer数据库分页:
语法:(关键字 top)
select top 10 * from 表名
分页sql:(条件查询每页10条数据)
默认第1页或者首页查询sql:
select top 10 * from SMS_TEMPLATE order by TEMP_ID
非首页查询sql:
select top 10TEMP_ID from SMS_TEMPLATE where TEMP_ID not in (
select top (PageIndex-1)*10 TEMP_ID from SMS_TEMPLATE order by TEMP_ID
) order by TEMP_ID