由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Re: 用Servlet显示数据库里的数据,分页的? (答案在这里)
相关主题
数据库问题求解请教一个mysql 排序问题。
如何对ORACLE的结果既分页又排序?random sampling with replacement, how?
用Servlet显示数据库里的数据,分页的? (很实际的问题)query 求助
how to fetch the first record from a table?奇怪的 SQL 问题
To get the 2nd, 3rd, 4th largest valueoracle pl sql recursive function
请问sql这个querry怎么写请教一下高手,包子答谢!
怎么用sql query 实现这个功能?correlated subquery
怎么用Update实现这个?请教关于exists在sql server中的用法
相关话题的讨论汇总
话题: rownum话题: select话题: line话题: what话题: firstname
进入Database版参与讨论
1 (共1页)
a*********e
发帖数: 35
1
多谢各位的指点,偶在一个newsgroup得到了一个答案,已经验证过了,
可以用应该还不错,贴出来大家看看,但是里面的实现好象没有在Oral
ce里见过. 麻烦那位帮我解释一下.
/***********
The answer is:
select "what you need" from (
select rownum line, "what you need" from "your table" )
where line between "start of subset" and "end of subset"
.....
E.g.:
select name, firstname from (
select rownum line, name, firstname from names)
where line between 10 and 20
order by name;
/***********************
B*****n
发帖数: 135
2
rownum is a psudocolumn in the result set, it will only be
incremented after a row has been actually selected (using
all the conditions except the one involving rownum
itself).
What i'm saying is that you cannot directly do a query
like this:
select "what you need" from "your table"
where rownum between 10 and 20;
because you never actully selected anything into the
result set, the rownum will never be greater than 0.
In other words, you want to select something based on the
rownum, while the ro

【在 a*********e 的大作中提到】
: 多谢各位的指点,偶在一个newsgroup得到了一个答案,已经验证过了,
: 可以用应该还不错,贴出来大家看看,但是里面的实现好象没有在Oral
: ce里见过. 麻烦那位帮我解释一下.
: /***********
: The answer is:
: select "what you need" from (
: select rownum line, "what you need" from "your table" )
: where line between "start of subset" and "end of subset"
: .....
: E.g.:

1 (共1页)
进入Database版参与讨论
相关主题
请教关于exists在sql server中的用法To get the 2nd, 3rd, 4th largest value
oracle和XML请问sql这个querry怎么写
MySQL数据库用户管理求助怎么用sql query 实现这个功能?
[转载] 求教数据库的query optimization 工作的面试怎么用Update实现这个?
数据库问题求解请教一个mysql 排序问题。
如何对ORACLE的结果既分页又排序?random sampling with replacement, how?
用Servlet显示数据库里的数据,分页的? (很实际的问题)query 求助
how to fetch the first record from a table?奇怪的 SQL 问题
相关话题的讨论汇总
话题: rownum话题: select话题: line话题: what话题: firstname