SQL之查询某几行记录--分页查询

本文介绍了在ORACLE、MYSQL和SQLSERVER中进行分页查询的不同方法。在ORACLE中,通过rownum和minus操作实现,而在MYSQL和SQLSERVER中,利用limit和top关键字进行分页。同时,文章还提及了SQL的between and用法。
摘要由CSDN通过智能技术生成

ORACLE:

1、查询前10行:select * from sc_objects where rownum <=10

2、利用minus

查询10到20行:select * from sc_objects where rownum <=20 minus select * from sc_objects where rownum <=10;

查询20行之后:select * from sc_objects minus select * from sc_objects where rownum <=20;
3、常用于
分页查询:

PAGESIZE:每页显示的记录数
CURRENTPAGE:当前页号
数据表的名字是:components
索引主键字是:id
select * from components where id not in(select id from components where rownum<=(PAGESIZE*(CURRENTPAGE-1))) and rownum<=PAGESIZE order by id;
如下例:
select * from sc_objects where id not in(select id from sc_object

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值