2018年6月26日 星期二

[SQL] 取第n至第m筆資料

MSSQL:

SELECT * FROM
(SELECT ROW_NUMBER() OVER (ORDER BY (select 0)) as ROWID, * FROM Products) VM
WHERE VM.ROWID BETWEEN n AND m

MySQL:

SELECT * FROM Products LIMIT n, (m-n+1)

沒有留言:

張貼留言