List:General Discussion« Previous MessageNext Message »
From:Aaron Fischer Date:June 5 2009 1:09pm
Subject:Ordering an IN query
View as plain text  
I have a query that I build dynamically, here is an example:

select from (table1 as t1 left join table2 as t2 on t1.id = t2.id)  
left join table3 as t3 on t1.id = t3.id where t1.id in ('221593',  
'221591', 'CC3762', 'CC0059')

So I build the query in the order that I want it displayed.  That is  
display 221593, then 221591, then CC3762, etc.  However, when the  
query is executed it looks like it automatically sorts the codes in  
ascending order, so I get 221591, then 221593, the CC0059, etc.

I want the results displayed in the order that I build the query.  Is  
there some way of doing that?

Thanks,

-Aaron
Thread
Ordering an IN queryAaron Fischer5 Jun
  • RE: Ordering an IN queryMartin Gainty5 Jun
  • Re: Ordering an IN queryPerrin Harkins5 Jun