不同数据库'查询第几行到第几行记录'脚本的区别
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;
以上是 不同数据库'查询第几行到第几行记录'脚本的区别 的全部内容, 来源链接: utcz.com/z/533105.html