DataGrid连接Access的快速分页法(3)——SQL语句的选用(降序)
2004-03-08 11:26
471 查看
DataGrid连接Access的快速分页法(3)——SQL语句的选用(降序)
三、降序
(1)@PageIndex <= @FirstIndexSELECT TOP @PageSize @QueryFields FROM @TableName WHERE @Condition ORDER BY @PrimaryKey DESC |
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 |
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 |
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的快速分页法(3)——SQL语句的选用(降序)
- 转载]DataGrid连接Access的快速分页法(2)——SQL语句的选用(升序)
- DataGrid连接Access的快速分页法(2)——SQL语句的选用(升序)
- DataGrid连接Access的快速分页法(2)——SQL语句的选用(升序)
- DataGrid连接Access的快速分页法——动态生成SQL语句
- DataGrid连接Access的快速分页法(4)——动态生成SQL语句
- DataGrid连接Access的快速分页法(3)——SQL语句的选
- DataGrid连接Access的快速分页法(4)——动态生成SQL语句
- DataGrid连接Access的快速分页法
- DataGrid连接Access的快速分页法(1)——需求与现状
- DataGrid连接Access的快速分页法(1)——需求与现状
- DataGrid连接Access的快速分页法(5)——实现快速分页
- [轉]DataGrid连接Access的快速分页法
- DataGrid连接Access的快速分页法(5)——实现快速分页
- DataGrid连接Access的快速分页法(1)——需求与现状
- DataGrid连接Access的快速分页法(1)——需求与现状
- 分页 sql 语句 及在 asp.net 中自定义 datagrid 分页
- java 连接SQL,Oracle,access,excel表的语句
- DataGrid基于Access的快速分页法(链接)