nofel — 2011-11-03T06:16:05-04:00 — #1
i got mysql query. i am using order by first_nameASC, but now i wan't another column with got values of pass or fail to to sorted too e.g pass comes on top and fail comes below it. can i apply order by on multiple column or is there any order way around?
immerse — 2011-11-03T06:20:48-04:00 — #2
Yes, you can do that:
SELECT name, score FROM results ORDER BY pass_or_fail DESC, first_name ASC;
This is assuming pass_or_fail is a boolean field indicating 1 for a pass, 0 for a fail.
nofel — 2011-11-03T08:42:48-04:00 — #3
its datatype is double not bool
guido2004 — 2011-11-03T08:47:20-04:00 — #4
'pass' and 'fail' seem strings to me
What value in your double column indicates 'pass', and what value indicates 'fail'?
nofel — 2011-11-03T09:03:39-04:00 — #5
Actually i have two option (pass,fail was a dummy case), either its disqualified or amount of money. data type is double
guido2004 — 2011-11-03T09:15:29-04:00 — #6
Disqualified? What value is that? NULL?
nofel — 2011-11-03T09:17:07-04:00 — #7
guido2004 — 2011-11-03T09:20:29-04:00 — #8
Ok, then Immerse's solution will work just fine.
To sort in reverse order, add the DESC (descending) keyword to the name of the column in the ORDER BY clause that you are sorting by. The default is ascending order; this can be specified explicitly using the ASC keyword.
nofel — 2011-11-03T09:33:49-04:00 — #9
guido2004 — 2011-11-03T09:54:03-04:00 — #10
What does that mean? Is it not sorting the right way?
is it possible that the query's 0 value is shown as Disqualified on fronted? or am i looking at some wrong column
You lost me here. Is this something you would like, or is it something that is already happening?