mysql資料庫: ① SELECT * FROM table LIMIT [offset,] rows | rows OFFSET offset; ② SELECT * FROM table ORDER BY id LIMIT [offset,] rows | rows OFFSET offset ...
mysql資料庫:
① SELECT * FROM table LIMIT [offset,] rows | rows OFFSET offset;
② SELECT * FROM table ORDER BY id LIMIT [offset,] rows | rows OFFSET offset;
pgsql資料庫:
① SELECT * FROM table LIMIT 10 OFFSET 20;
② SELECT * FROM table ORDER BY id LIMIT 10 OFFSET 20;
mssql資料庫:
① SELECT TOP 10 * FROM table WHERE id in (SELECT TOP 20 id FROM table ORDER BY id) ORDER BY id DESC;
② SELECT IDENTITY(int,1,1) id,* INTO temp FROM table;SELECT * FROM temp id BETWEEN 10 AND 20;
oracle資料庫:
① SELECT * FROM table WHERE rownum < 20
minus
SELECT * FROM table WHERE rownum < 10;
② SELECT * FROM (SELECT t.*, row_number() over(ORDER BY id)rowid FROM table t) WHERE rowid BETWEEN 10 AND 20;