提取数据库表中中间不定条数的记录
2009-09-08 19:44
176 查看
首先你的数据库要有可以唯一排序的字段,比如ID或者编号之类。
假定你用id进行唯一排序,那么提取第100到第200条记录的语句就是:
select top 100 * from table where id>(select max(id) from (select top 100 id from table order by id asc) as tblTmp) order by id asc
假定你每页显示数量为Point,当前页码为Page,那么显示该页所有记录的SQL语句应该是:
sql = "select top " & Point & " * from table where id>(select max(id) from (select top " & (Page - 1) * Point & " id from table order by id asc) as tblTmp) order by id asc
假定你用id进行唯一排序,那么提取第100到第200条记录的语句就是:
select top 100 * from table where id>(select max(id) from (select top 100 id from table order by id asc) as tblTmp) order by id asc
假定你每页显示数量为Point,当前页码为Page,那么显示该页所有记录的SQL语句应该是:
sql = "select top " & Point & " * from table where id>(select max(id) from (select top " & (Page - 1) * Point & " id from table order by id asc) as tblTmp) order by id asc
相关文章推荐
- 数据库取中间几条记录
- PHP查询数据库中满足条件的记录条数(二种实现方法)
- PHP查询数据库中满足条件的记录条数(两种实现方法)
- 随机提取N条记录[多种数据库方法]
- 用于查询当前数据库中所有表格的记录条数的脚本
- SQL语句,查询数据库中间连续的记录
- PHP查询数据库中满足条件的记录条数(两种实现方法)
- PHP查询数据库中满足条件的记录条数(二种实现方法)
- 数据库提取前10条记录
- 用于查询当前数据库中所有表格的记录条数的脚本
- SQL提取数据库记录按字的笔画排序
- yii计算数据库的记录条数
- 使用JDBC批量删除数据库记录条数
- sql查询数据库中所有表的记录条数,以及占用磁盘空间大小。
- NHibernate使用ICriteria分页并返回数据库记录总条数
- 从数据库中随机提取10条记录
- 统计一个数据库中所有表的总记录条数
- ajax+jsp提取数据库记录并实现自动刷新页面
- 用于查询当前数据库中所有表格的记录条数的脚本
- 数据库修改多对多的中间表的记录的技巧