大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说不同数据库’查询第几行到第几行记录’脚本的区别[通俗易懂],希望您对编程的造诣更进一步.
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;
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/9035.html