方法一:
適用於 SQL Server 2000/2005SELECT TOP 頁大小 *
FROM table1
WHERE id NOT IN
(
SELECT TOP 頁大小*(頁數-1) id FROM table1 ORDER BY id
)
ORDER BY id
方法二:
適用於 SQL Server 2000/2005SELECT TOP 頁大小 *
FROM table1
WHERE id >
(
SELECT ISNULL(MAX(id),0)
FROM
(
SELECT TOP 頁大小*(頁數-1) id FROM table1 ORDER BY id
) A
)
ORDER BY id
方法三:
適用於 SQL Server 2005SELECT TOP 頁大小 *
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* FROM table1
) A
WHERE RowNumber > 頁大小*(頁數-1)
方法四:從第 M 筆資料開始取 N 筆 - SQL Server SELECT *
FROM ( SELECT Top N *
FROM (SELECT Top (M + N - 1) * FROM table1 Order by id desc) t1 ) t2
Order by id asc
方法五:從第 M 筆資料開始取 N 筆 - OralceSELECT *
FROM (SELECT ROWNUM r,t1.* From table1 t1 where rownum < M + N) t2
where t2.r >= M
方法六:從第 M 筆資料開始取 N 筆 - MySQLSELECT * FROM table1 LIMIT M,N
留言列表