SQLServer分页


分页查询==>
方法1:
(ROW_NUMBER()函数)语句形式:
select * from (
select *,ROW_NUMBER() OVER (ORDER BY column_name) as rank from table_name
) as t where t.rank between 3000001 and 3000010

方法2 (利用IN)语句形式:
select top 10 * from tbl_name where FlightsDetailID in(
select top 10 FlightsDetailID from(
select top 3000010 FlightsDetailID from tbl_name order by FlightsDetailID
) as t order by t.FlightsDetailID desc
) order by FlightsDetailID

方法3 (利用Not In)语句形式:
select top 10* from tbl_FlightsDetail where FlightsDetailID not in (
select top 3000000 FlightsDetailID from tbl_FlightsDetail order by FlightsDetailID
) order by FlightsDetailID

方法4 定位法 (利用ID大于多少)语句形式:
select top 10 * from tbl_FlightsDetail where FlightsDetailID>(
select max(FlightsDetailID) from (
select top 3000000 FlightsDetailID from tbl_FlightsDetail order by FlightsDetailID
) as t
) order by FlightsDetailID

SQLServer分页,布布扣,bubuko.com

SQLServer分页

上一篇:[Microsoft][ODBC Microsoft Access Driver] INSERT INTO 语句的语法错误。


下一篇:JSON(04)PHP的JSON处理函数及将MySQL结果集快速转为JSON的方法