Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg:Getting vaues from DB with out sorting

 
kirans reddy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to get data from Employee table like

select * from Employee where id in(8,7,5,9,1);

It is fetching data like

1
5
7
8
9
But i need like
8
7
5
9
1

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a few choices:
1) Do the queries one at a time
2) Do the "sort" in your desired order after getting back from the database if using JDBC
3) Sort in Oracle. I think you can define a custom function (which returns your desired order) and sort by that. (I did it in a different database, but I think Oracle supports it too.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic