File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes SQL question 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 "SQL question" Watch "SQL question" New topic

SQL question

Max Harding

Joined: Aug 24, 2002
Posts: 2
What would be the proper SQL statement to use if I wanted to access the 11th row of a table without any comparison to data in that particular row?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You can access the 11th record in a result set by just looping thru the resultset and increment a counter till you reach 11.

So much trouble in the world -- Bob Marley
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

If you are using Oracle, you can do something like
"select id, name from ( select rownum as row_num_col, id, name from emp ) where row_num_col = 11"
To find the rownumber in a database is database specific, so the above may not work on any other platform.
I agree. Here's the link:
subject: SQL question
It's not a secret anymore!