database - How to order by multiple fields in MySQL? -


i'm looking order data in specific way have explicitly laid out fields want appear first. basically, i'm looking return mysql query doing imagine might this:

order   field(brand,'toyota','honda','ford'),   field(type, 'suv', 'sedan', 'coupe'),   field(transmission, 'manual', 'automatic', 'cvt') 

simply said i'm looking way order things based on multiple fields. i've tried doesn't seem working. can done or after specify order of 1 field have order other things either asc or desc?

thanks help!

perhaps this?

select brand, type, transmission       tablename  order   case brand   when 'toyota' 1   when 'honda' 2   when 'ford' 3  end asc,  case type   when 'suv' 1   when 'sedan' 2   when 'coupe' 3  end asc,  case transmission   when 'manual' 1   when 'automatic' 2   when 'cvt' 3  end asc 

http://www.devx.com/tips/tip/17288


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -