It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes How to select a range of rows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to select a range of rows" Watch "How to select a range of rows" New topic

How to select a range of rows

igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
Hello, I want to use my SQL select statement to select a certain number of records within a range. For example, if I use the SQL statement

select * from mychildren.

I would get a resultset containing x amount of rows, say 2000.
Now my problem is that for my program retrieveing 2000 rows from a table is both memory and time consuming. Can I just choose from row 1 to 50. then decide to select from row 51 to 100 and the like. Is this possible in SQL.

If I select incrementally the program can run a lot faster. Thanks and please let me know if this is possible or other possible solutions.
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Read about FETCH, it will be database dependent, but here you have link to DB2.

SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
I agree. Here's the link:
subject: How to select a range of rows
It's not a secret anymore!