zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

SQLSever查询第11行到第25行的数据,sql分页查询 ( offset 10 rows fetch next 15 rows only)详解数据库

数据库SQL数据 详解 查询 10 11 分页
2023-06-13 09:20:09 时间

使用: order by 字段 desc/asc offset 开始行数 rows fetch next 显示行数 rows only 查询第几行到第几行的数据

使用:order by 字段 offset ((第几页 1)* 每页数量) rows fetch next 每页数量 rows only 查询分页

--order by 字段 desc/asc offset 开始行数 rows fetch next 显示行数 rows only 

--查询第11行到25行数据 

SELECT * FROM [employeesss] order by EmployeeId offset 10 rows fetch next 15 rows only 

--order by 字段 offset ((第几页 - 1)* 每页数量) rows fetch next 每页数量 rows only 

--例:第二页,每页5条数据 

select * from employeesss order by EmployeeId offset (2 -1) * 5 rows fetch next 5 rows only 

--例:第三页,每页5条数据 

select * from employeesss order by EmployeeId offset (3 -1) * 5 rows fetch next 5 rows only 

结果显示:
在这里插入图片描述

4212.html