Want to be able to order by two or more database fields / columns using the ASC and DESC order clause
You can sort query results in ascending or descending order on one or more of the columns in the result set by using the ASC or DESC keywords with the ORDER BY clause.
Ordering By Two Fields
SELECT * FROM table ORDER BY (field1 / field2) DESC
Ordering By Three Fields
If both field1 and field2 match in more then one row, then use a third to order them by:
SELECT * FROM table ORDER BY (field1 / field2) DESC, field3 DESC


(23 votes, average: 4.39 out of 5)
This is a cool explanation… i was looking for that. Thanks
this was great! thanks!
great answer – thanks!
Actually the above code did not work for me. This does:
ORDER BY FIELD1,FIELD2 ASC
(or DESC, etc)
Thanks Alot dear
Its really working
Thanks man I love you
Thanks you =)
thx for the info, but in my case the solution was the use of GREATEST(fieldA,fieldB) as XXX order by XXX…
i learn it oN this posT ::
http://teethgrinder.co.uk/perm.php?a=MySQL-max-of-two-columns
pD :: i hope be useful
You are a lifesaver
Great! Thank you very much!