SELECT TOP 頁大小 *
FROM table1
WHERE id NOT IN
(
SELECT TOP 頁大小*(頁數-1) id FROM table1 ORDER BY id
)
ORDER BY id
select top 10 * from 表名--查詢顯示0-10條記錄(10條)
select top 10 *from 表名 where 主鍵 not in(select top 10 表名 from 主鍵);--查詢顯示11-20條記錄(10條)
select top 10* from表名 where 主鍵not in (select top 20 表名 from 主鍵);--查詢顯示21-30條記錄(10條)
select top 10* from表名 where 主鍵not in (select top 30表名 from 主鍵);--查詢顯示31-40條記錄(10條)
例如:
select top (@pageSize) * from books where id not in
(select top ((@pageIndex-1)*@pageSize) id from books order by id) order by id