2010-08-09 34 views
0

我想知道如何使用MySQL訂購數字和非數字值。如何在MySQL中訂購數字和非數字值

以下是輸出結果。

1 
10 
1234 
2 
25 
26 
a 
b 
c 
d 

這是我想要的。

1 
2 
10 
25 
26 
1234 
a 
b 
c 
d 

這是我的MySQL代碼。

SELECT tags.*, 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 
+1

檢查出http://stackoverflow.com/questions/153633/natural-sort-in-mysql,我想你想要一個自然的排序,這可悲的是不存在於mysql中。 – 2010-08-09 01:50:10

+0

布蘭登我認爲這個評論應該是一個答案 – thomasrutter 2010-08-09 02:32:37

回答