按字母顺序对MySQL结果进行排序,但最后一个数字 [英] Sort MySQL results alphabetically, but with numbers last
问题描述
通常,排序是通过将符号排在顶部来完成的,例如0
或*
或&
.这是mysql排序的默认方式.数字和符号,然后按A-Z.但是,这会使通常最丑陋或格式最糟糕的结果浮动到顶部(例如@#$@3423
或8 inch
或&
的结果).
Often, sorting is done with symbols sorted to the top, like 0
or *
or &
. This is the default way that mysql sorts; numbers and symbols and then A-Z. However, that makes the often ugliest or most badly formatted results float to the top (e.g. a result of @#$@3423
or 8 inch
or &
).
所以我想做一个修改后的形式,先字母A-Z,然后是特殊字符.
So I'd like to do a modified form of that, letters first A-Z, and then special characters last.
我将如何创建这种类型的排序? ORDER BY
子句中有内容?
How would I go about creating that type of sort? Something in the ORDER BY
clause?
推荐答案
Based on a google-cached link to this page:
http://www.google.com/url?sa=t&source=web&cd=3&ved=0CCUQFjAC&url=http%3A%2F%2Fblog.feedmarker.com%2F2006%2F02%2F01%2Fhow-to-do-natural-alpha-numeric-sort-in-mysql%2F&ei=Zg2_TZyKDaffiALjjqwo&usg=AFQjCNGS-rX7AmfrumXK8J7bVSj96bSSmQ
原始链接已死. 这是另一个链接,它实际上解释了比第一个链接更好的事情:
Original link is dead. Here is another link which actually explains what is happening better than the first link did:
http://matthewturland.com/2008/11/05 /natural-ordering-in-mysql/
您可以尝试
SELECT names FROM your_table ORDER BY names + 0 ASC
这篇关于按字母顺序对MySQL结果进行排序,但最后一个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!