分页

自己写的分页查询语句

默认分类 2009-12-15 11:47:36 阅读14 评论0   字号: 订阅

最常用简单分页

select top 20 * from feedback_form where id not in (select top 页码*20 id from feedback_form WHERE 1=1 and status>0 and status < 5 order by id desc) order by id desc

sql="select top "&size&" * from

(select TOP 100 PERCENT

substring([cityKey],charindex(':',[cityKey])+1,len([cityKey]) -charindex(':',[cityKey])) as a,developer,salesPhone,childId,buildName,fieldPosition,overviewPhoto,equalPrice,C.unitType,left([cityKey],charindex(':',[cityKey])-1) as pid,C.outPhoto

from hellohouse_houseChild as C join hellohouse_houseRoot as R on C.rootId=R.rootId

where "&whereStr1&" order by childId desc) as a where childId not in (select top ("&size&"*"&page-1&") childId

from (select TOP 100 PERCENT

substring([cityKey],charindex(':',[cityKey])+1,len([cityKey]) -charindex(':',[cityKey])) as a,developer,salesPhone,childId,buildName,fieldPosition,overviewPhoto,equalPrice,C.unitType,left([cityKey],charindex(':',[cityKey])-1) as pid,C.outPhoto

 from hellohouse_houseChild as C join hellohouse_houseRoot as R on C.rootId=R.rootId

where "&whereStr1&" order by childId desc) as b order by childId desc) order by childId desc"

用于www.whhouse.com 的最新楼盘分页查询~太复杂了啊~效率也没达人的好,不过总算能解决问题了

2009-12-15 杨志翔

原文地址:https://www.cnblogs.com/21xz/p/1861629.html