跳过然后取一些结果(分页)

ISO / ANSI SQL:

SELECT Id, Col1
FROM TableName
ORDER BY Id
OFFSET 20 ROWS FETCH NEXT 20 ROWS ONLY;

MySQL 的:

SELECT * FROM TableName LIMIT 20, 20; -- offset, limit

甲骨文; SQL Server:

SELECT Id,
   Col1
 FROM (SELECT Id,
           Col1,
           row_number() over (order by Id) RowNumber
      FROM TableName)
WHERE RowNumber BETWEEN 21 AND 40

PostgreSQL 的; SQLite 的:

SELECT * FROM TableName LIMIT 20 OFFSET 20;