Results 1 to 5 of 5
Thread: Sorting questions (MySQL)
May 8, 2013, 13:08 #1
- Join Date
- Apr 2013
- 0 Post(s)
- 0 Thread(s)
Sorting questions (MySQL)
I have a couple of ORDER BY questions that I hope someone can and want to answer.
1) Is there any easy way I can achieve a natural sorting order with both numbers and letter (i.e. 1, 2, 10, 11, 20, 100, a2, a100, b5 etc.) in MySQL? I've found some suggestions involving ASC 0, but they don't seem to work when letters are involved.
2) Is there any way to create a sort on SQL level (rather than, e.g., PHP) that puts all rows with a certain value at the end of the list, for example 0 in an INT column that contains years. In the cases where the years is unknown the rows have 0, which I would like to come last in both ascending and descending order. Similarly with empty strings in other column types.