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 order in select query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "order in select query" Watch "order in select query" New topic

order in select query

shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
i have a query for example "select * from table where id in (13,19,17,16,25)". i want the resulting rows in the order given in "in section". Is this possible??
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
i just changed my query and using preparedstatement thereby able to restore the order i had asked for. hope the difference is not much when it comes to performance.anyways i would like to know if using a single select and "in", is it possible to restore the order given in the "in"...
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
Hi Shankar
In oracle, it is possible to achieve that through a single select statement. You have to write a decode function in your order by clause. I am not sure about the other databases.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: order in select query
jQuery in Action, 3rd edition