mysql custom sorting first alpha then numeric using case when
- by Nizzy
How can you sort a query using ORDER BY CASE WHEN REGEXP? or other alternatives?
I don't want to use UNION. Thank you
mysql> SELECT `floor_id`, `floor_number` FROM `floors`;
+----------+--------------+
| floor_id | floor_number |
+----------+--------------+
| 1 | 4 |
| 2 | 7 |
| 3 | G |
| 4 | 19 |
| 5 | B |
| 6 | 3 |
| 7 | A |
+----------+--------------+
Expected result:
+----------+--------------+
| floor_id | floor_number |
+----------+--------------+
| 7 | A |
| 5 | B |
| 3 | G |
| 6 | 3 |
| 1 | 4 |
| 2 | 7 |
| 4 | 19 |
+----------+--------------+