---sqlServer 2005 分页语句集合 ----缺点: -- top:必须用户编写复杂sql,不支持复合主键 -- max:必须用户编写复杂sql,不支持非唯一列排序 --row:不支持sqlserver2000 -------------------------------- select TOP @pagesize id,email,qq,wechart,phone,phone1 FROM contact where id not in (SELECT TOP (@pagesize*(currentpage-1)) id from contact ORDER BY id ASC ) ORDER BY id ASC -- 效率最低下的分页语句(只需要知道页数和每页的显示数目即可) select * from AISINO_BD_TelephoneRecord order by ID asc; select top 5 ID,companyID,projectID from dbo.AISINO_BD_TelephoneRecord where ID not in( select top (5*(2-1)) ID from AISINO_BD_TelephoneRecord order by ID asc ) order by ID asc ----------------------第二种方法,只需要知道页数和每页的显示数目即可------------------------------- select top 5 * from AISINO_BD_TelephoneRecord where ID>( select max(ID) from (select top (5*(2-1)) ID from AISINO_BD_TelephoneRecord order by ID asc)tt ) order by ID asc -------------------第三种方法---只需要知道页数和每页的显示数目即可---------------------------------- select * from (select top (5*(1-1)+5) row_number()over(order by Id asc)__rn__,* from AISINO_BD_TelephoneRecord)t where __rn__>5*(1-1)
在oracle 中的分页:
oracle 自带了rownum,直接使用rownum 进行分页:
select * from (select a.*,rownum nm from (select * from aos_rms_user) a where rownum <= 5*(1-1)+5) where nm >= 5*(1-1)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。