1.分頁方案一:(利用not in和select top分頁)
語句形式:
selecttop 頁大小*
from testtable
where(id not in
(select top 頁大小*頁數 id
from 表
orderby id))
orderby id
(sql2000 northwind.customers表)
select top 10 *
from customers
where (customerid not in (select top 20 customerid from customers order by customerid))
order by customerid
(查詢第二頁,每頁10條資料)
2.分頁方案二:(利用id大於多少和select top分頁)
語句形式:
select top 10 *
from testtable
where(id > (select max(id)
from(select top20id
from testtable
orderby id)
ast)
)
orderby id
selecttop頁大小*
fromtesttable
where(id>
(selectmax(id)
from(selecttop頁大小*頁數id
from表
orderbyid)ast))
orderbyid
三種SQL分頁法效率分析
表中主鍵必須為標識列,id int identity 1,1 1.分頁方案一 利用not in和select top分頁 語句形式 selecttop10 fromtesttable where idnotin selecttop20id fromtesttable orderbyid orderb...
三種SQL分頁法
三種sql分頁法 表中主鍵必須為標識列,id int identity 1,1 1.分頁方案一 利用not in和select top分頁 語句形式 select top 10 from testtable where id not in select top 20 id from testtabl...
三種SQL分頁法
三種sql分頁法 表中主鍵必須為標識列,id int identity 1,1 1.分頁方案一 利用not in和select top分頁 語句形式 select top 10 from testtable where id not in select top 20 id from testtabl...