18410

Question:
I have multiple columns. Two of them are:
Group (numeric, not unique) Name (string, not unique)
I would need to order by Group descending, BUT, if the value "Name" equals "Empty" i should be displayed at the end of the Group...
Group Name
1020 test1
1020 test2
1020 test3
1020 EMPTY <-- end of Group 1020
1020 EMPTY <-- end of Group 1020
3040 test6
3040 test7
3540 test8
3540 EMPTY <-- end of Group 3540
15060 test9
15060 EMPTY <-- end of Group 15060
How can this be done with a mysql query?
Answer1:In MySQL, expressions like Name = 'EMPTY'
have the value 1
if true and 0
if false.
So you can use
ORDER BY Group, Name = 'EMPTY', Name
to get all the not-EMPTY values first, then all the EMPTY ones.