This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

order in select query

 
shankar vembu
Ranch Hand
Posts: 309
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
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.
 
shankar vembu
Ranch Hand
Posts: 309
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"...
shankar.
 
Sainudheen Mydeen
Ranch Hand
Posts: 218
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Thanks
-Sainudheen
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic