SQL常用的分页(Top,Row_Number)

SQL分页查询语句

1.TOP分页


--分页为10条数据
Select Top 10 * 
From Table
Where Id not in
(
--第几页
 Select Top 1 *
 From Table
Order By Id ASC
)
Order By Id

2. ROW_NUMBER() 分页

--ROW_NUMBER()取前十条数据
Select Top 10 * From(
--将查询的表加上连续的rownumber的排序字段
--其本身不存在实体表中
Select ROW_NUMBER() over(Order by Id) 
as rownumber, * From Table
) as Temp 
Where rownumber between 1 and 10



猜你喜欢

转载自blog.csdn.net/qq_40122860/article/details/80367519