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
Comments
Post a Comment