Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes How to select resultset in range? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "How to select resultset in range?" Watch "How to select resultset in range?" New topic
Author

How to select resultset in range?

Conie Ooi
Ranch Hand

Joined: Jun 09, 2002
Posts: 31
Hi, I'm in a situation which I need to select rows from table in a range, let's say from record 3 to record 5. Is there any command in DB2 can do the job for me?
Thanks a lot and waiting for your reply..
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
Can you explain a little more what you're trying to do? It seems a little odd that you need to select rows 3-5 in a table like that. Isn't there a specific field value(s) you can add to your WHERE clause to identify the records you need? Sorry, maybe I'm just misunderstanding you :roll:


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Conie Ooi
Ranch Hand

Joined: Jun 09, 2002
Posts: 31
i've found the solution to my problem already.. thanks a lot..
timothy passcal
Greenhorn

Joined: Oct 23, 2003
Posts: 9
I know this thread is really old....
Does anyone have a solution on how to do this in DB2?
Select * from X where database returns only rows 21 through 30.
Thanks.
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
I can't fully answer this, but I can send you in the right direction:
adding
"FETCH FIRST 40 ROWS ONLY"
to your SQL statement gets the first 40, but I don't think you can tell it to drop the first X amount.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26144
    
  66

dbForums has a good thread on this. You can do it with a nested query, but it will be very inefficient.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to select resultset in range?
 
Similar Threads
Did not understand the answer(John Meyers's mock exam)
Oracle Certification Query
how to solve this insert record problem ?
Data layer design.
Do we have policy like this?