分页查询的SQL语句
2013-12-19 11:37
190 查看
每页10个记录,查询出第2页的记录
如果不带查询条件:
select top 10 * from WorkRecord
where (Id not IN (select top (10 * 2) Id FROM WorkRecord))
如果带查询条件
select top 10 * from (select * FROM WorkRecord
where (CatchTime > '2013/11/18 0:00:00' and CatchTime < '2013/12/18 23:59:59')) tag
where (tag.Id not IN (select top (10 * 2) tag1.Id FROM (select * FROM WorkRecord
where (CatchTime > '2013/11/18 0:00:00' and CatchTime < '2013/12/18 23:59:59')) tag1))
如果不带查询条件:
select top 10 * from WorkRecord
where (Id not IN (select top (10 * 2) Id FROM WorkRecord))
如果带查询条件
select top 10 * from (select * FROM WorkRecord
where (CatchTime > '2013/11/18 0:00:00' and CatchTime < '2013/12/18 23:59:59')) tag
where (tag.Id not IN (select top (10 * 2) tag1.Id FROM (select * FROM WorkRecord
where (CatchTime > '2013/11/18 0:00:00' and CatchTime < '2013/12/18 23:59:59')) tag1))
相关文章推荐
- 海量数据库的查询优化及分页算法方案(二)-改良SQL语句 [转]
- SQL分页查询语句
- 关于SQL Server SQL语句查询分页数据的解决方案
- SQL分页查询语句分析
- 查询结果分页显示的sql语句
- 分页排序的SQL查询语句
- mybatis分页多条件查询指定时间段数据的sql语句
- 分页查询十万条以上数据的sql语句
- mysql、MS SQL关于分页的sql查询语句 limit 和row_number() OVER函数
- 用标准的SQL语句实现查询记录的分页
- Oracle、SQL server、MySQL数据库中分页查询的SQL语句
- PHP——分页显示的完善(加查询,用类简化sql语句)
- 海量数据库的查询优化及分页算法方案(3)--改善SQL语句[转]
- SqlServer2005高效分页sql查询语句汇总
- 又一个通用分页存储过程,支持表别名,多表联合查询SQL语句--转载
- SqlServer2005高效分页sql查询语句汇总
- SqlServer2005高效分页sql查询语句
- Oracle分页查询Sql语句例子
- Oracle和MySQL分页查询SQL语句
- 几种常用数据库 分页查询的sql语句和简单分析