开发者

How to order numeric and non-numeric values in MySQL

开发者 https://www.devze.com 2023-01-10 13:58 出处:网络
I was wondering how can I order numeric and non-numeric values using MySQL. Here is what is outputed. 1

I was wondering how can I order numeric and non-numeric values using MySQL.

Here is what is outputed.

1
10
1234
2
25
26
a
b
c
d

Here is what I want.

1
2
10
25
26
1234
a
b
c
d

Here is my MySQL code.

SELECT tags开发者_StackOverflow.*, COUNT(tag_id) as number_of_tags 
FROM tags 
INNER JOIN posts_tags ON tags.id = posts_tags.tag_id
GROUP BY tags.tag
ORDER BY tags.tag ASC


Check out Natural Sort in MySQL, I think you want a natural sort, which sadly does not exist in mysql yet.

0

精彩评论

暂无评论...
验证码 换一张
取 消