MySQL 'Order By' - sorting alphanumeric correctly

后端 未结 15 2108
执念已碎
执念已碎 2020-11-22 12:02

I want to sort the following data items in the order they are presented below (numbers 1-12):

1
2
3
4
5
6
7
8
9
10
11
12

However, my query - using

15条回答
  •  隐瞒了意图╮
    2020-11-22 12:36

    SELECT s.id, s.name, LENGTH(s.name) len, ASCII(s.name) ASCCCI FROM table_name s ORDER BY ASCCCI,len,NAME ASC;

提交回复
热议问题