关于rownum的使用?

[复制链接]
查看11 | 回复3 | 2005-2-28 12:57:00 | 显示全部楼层 |阅读模式
用select检索数据的时候,
为什么我用rownum5000 and rownum5000 and rownum<10000或者 rownum between 5000 and 10000 结果为空呢??????
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
你最好看一下ROWNUM的含义.
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
ROWNUM is a pseudocolumn.As values are read into thecache they are assigned a value.The numbers are dynamic they change for every query.Thus the exact same rowcould have a different rownum depending on the number of rows that were read into the cache.
select rownum, columna, columnb from test;
ROWNUM COLUMNACOLUM
---------- ---------- -----
1
1 a
2
2 b
3
3 c<-------- rownum = 3
4
4 d
5
5 e
5 rows selected.
select rownum, columna, columnb from test where columna = 3;
ROWNUM COLUMNACOLUM
---------- ---------- -----
1
3 c<--------- rownum = 1
1 row selected.
The rownum is different for the same row depending on the other values that are returned with the query.
In any event, there must be rownum of 1 returned before the 2 can be returned.Querying the values with therownum= value (i.e. 3) is an invalid statement, it will always return with a 'No Rows Selected' message.
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
只能用rownum<n这种格式
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行