sql 分页查询
引用:http://space.itpub.net/26273/viewspace-704021
初始定义:
pageSize:每页显示大小
pageNum:第几页
Oracle分页:
minus差分页:
select * from table where rownum<=pageSize*pageNum minus select * from table where rownum<=(pageSize-1)*pageNum
例子:
select * from table where rownum<=10 minus select * from table where rownum<=5
两个关联表的符合条件记录的交集,是于union作用相反.
例:
select * from table where rownum<=20
minus
select *from table where rownum<=10
SQLServer分页:
select top pageSize*pageNum from table where id not in(select top (pageSize-1)*pageNum id from table );
例子
select top 5 * from table where id not in(select top 0 id from table);
MySQL分页:
select * from table limit (pageSize-1)*pageNum,pageSize*pageNum;
例子:
select * from table limit 0,5;