• Post Reply Bookmark Topic Watch Topic
  • New Topic

sql query regarding order  RSS feed

 
swapnil kataria
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please see the query

SELECT * FROM EMP_LIST WHERE
NAME LIKE '%RAHUL%' OR
NAME LIKE '%SMITH%' OR
NAME LIKE '%SANJANA%' OR
NAME LIKE '%AMIT%' ;

when i run this query, it is retrieving records fine, but it is not coming in proper order,

i means, i want records mathcing 'RAHUL' should come first, and then records matching 'SMITH' should come second and so on,

is there any way to handle order is such a way, please help
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about SQL's ORDER BY clause?

I'll move this thread to our JDBC forum.
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a simple SQL query using the "ORDER BY" clause will result in alphabetically ordered records. However, it will not order as you have specified.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!