Click to See Complete Forum and Search --> : need help on custom order by


charaseac
10-09-2008, 05:43 PM
Greetings!

im using oracle 9 and im using
JDBC connection for my application.

Basically this is what happens, i have this table called symbol, and in this i have a column called name.

My application right now do a search in the name.

For example, when user enters "micro" in the search box, the application will run a sql statement which will look into symbol table with name that contains "micro" in it. Then right now it is ordered alphabetically.

What i want to do is to order it in this way:
- names that start with the word the user search will be the first ones to appear
- and the rest will be sorted alphabetically

for example if user search for microsoft it will return something like

microsoft
micro virus
microworld
abe micro goods
trend micro AV

something like that.
Stumbled across order by case.. tried that, it doesnt work. Anyone can help me with this?

Thanks!

chazzy
10-09-2008, 07:09 PM
i think you should use a temp table. first, dump all contents that match micro%. then find all that match %micro% and aren't in the temp table. use the order by in each of those queries to return them in this order.