File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes sql query regarding order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "sql query regarding order" Watch "sql query regarding order" New topic
Author

sql query regarding order

swapnil kataria
Ranch Hand

Joined: Feb 26, 2011
Posts: 64
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

Joined: Oct 27, 2005
Posts: 19543
    
  16

How about SQL's ORDER BY clause?

I'll move this thread to our JDBC forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

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.


S.D. MADHAN
Not many get the right opportunity !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sql query regarding order
 
Similar Threads
JDBC : ODBC bridge
Sample SQL question
sorting the result
what's your smooth comeback?
How to get the records from data base in chunk