各种数据库分页查询sql语句
select * from
(select a.*,rownum rc from 表名 where rownum<=endrow) a
>=startrow;
2.DB2数据库分页
Select * from数据库优化sql语句
(select rownumber() over() as rc,a.* from
(select * from 表名 order by 列名) as a)
where rc between startrow and endrow;
3.SQL Server 2000数据库分页
Select top pagesize * from 表名
where 列名 not in
(select top pagesize*page 列名 from 表名 order by 列名)
order by 列名;
4.SQL Server 2005数据库分页
Select * from
(select 列名,row_搜索number() over(order by 列名1) as 别名from 表名) as t
where t.列名1>=startrow and t.列名1<=endrow;
5.MySQL数据库分页
Select * from 表名 limit startrow,pagesize; (Pagesize为每页显⽰的记录条数)
优化写法  Select a.* from表名 a,(Select id from 表名 order by id limit startrow,pagesize) b where a.id=b.id;
6.通⽤模式
select * from
(select * from student where sid not in
(select sid from student where rownum<=(currentPage-1)*pageSize)
) where rownum <=pageSize;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。