DataGrid连接Access的快速分页法(3)——SQL语句的选
2008-04-24 10:12
615 查看
DataGrid连接Access的快速分页法(3)——SQL语句的选用(降序)
三、降序
(1)@PageIndex <= @FirstIndexSELECT TOP @PageSize @QueryFields FROM @TableName WHERE @ConditionORDER BY @PrimaryKey DESC (2)@FirstIndex < @PageIndex <= @MiddleIndex SELECT TOP @PageSize @QueryFields FROM @TableName WHERE @PrimaryKey < ( SELECT MIN(@PrimaryKey) FROM ( SELECT TOP @PageSize*@PageIndex @PrimaryKey FROM @TableName WHERE @Condition ORDER BY @PrimaryKey DESC ) TableA ) WHERE @Condition ORDER BY @PrimaryKey DESC (3)@MiddleIndex < @PageIndex < @LastIndex SELECT * FROM ( SELECT TOP @PageSize @QueryFields FROM @TableName WHERE @PrimaryKey > ( SELECT MAX(@PrimaryKey) FROM ( SELECT TOP (@RecordCount-@PageSize*(@PageIndex+1)) @PrimaryKey FROM @TableName WHERE @Condition -- ORDER BY @PrimaryKey ASC ) TableA ) WHERE @Condition -- ORDER BY @PrimaryKey ASC ) TableB ORDER BY @PrimaryKey DESC (4)@PageIndex >= @LastIndex SELECT * FROM ( SELECT TOP (@RecordCount-@PageSize*@LastIndex) @QueryFields FROM @TableName WHERE @Condition ORDER BY @PrimaryKey ASC) TableA ORDER BY @PrimaryKey DESC四、总结
通过上面的讨论,相信大家应该看到了该分页方法的优势所在。在下一篇中,我将给大家一个动态生成上面 SQL 语句的类。 作者:黎波相关文章推荐
- 转载]DataGrid连接Access的快速分页法(2)——SQL语句的选用(升序)
- DataGrid连接Access的快速分页法(4)——动态生成SQL语句
- DataGrid连接Access的快速分页法(2)——SQL语句的选用(升序)
- DataGrid连接Access的快速分页法(3)——SQL语句的选用(降序)
- DataGrid连接Access的快速分页法(3)——SQL语句的选用(降序)
- DataGrid连接Access的快速分页法(2)——SQL语句的选用(升序与降序)
- DataGrid连接Access的快速分页法(4)——动态生成SQL语句
- DataGrid连接Access的快速分页法——动态生成SQL语句
- DataGrid连接Access的快速分页法(2)——SQL语句的选用(升序)
- [轉]DataGrid连接Access的快速分页法
- DataGrid连接Access的快速分页法(5)——实现快速分页
- DataGrid连接Access的快速分页法(1)——需求与现状
- DataGrid连接Access的快速分页法(1)——需求与现状
- DataGrid连接Access的快速分页法(1)——需求与现状
- DataGrid连接Access的快速分页法
- DataGrid连接Access的快速分页法(5)——实现快速分页
- DataGrid连接Access的快速分页法(1)——需求与现状
- DataGrid基于Access的快速分页法
- java 连接SQL,Oracle,access,excel表的语句
- Oracle、SQL Server、Access利用SQL语句进行高效果分页