按字母顺序对MySQL结果进行排序,但最后一个数字 [英] Sort MySQL results alphabetically, but with numbers last

查看:268
本文介绍了按字母顺序对MySQL结果进行排序,但最后一个数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,排序是通过将符号排在顶部来完成的,例如0*&.这是mysql排序的默认方式.数字和符号,然后按A-Z.但是,这会使通常最丑陋或格式最糟糕的结果浮动到顶部(例如@#$@34238 inch&amp的结果).

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 &amp).

所以我想做一个修改后的形式,先字母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?

推荐答案

基于此页面的Google缓存链接:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆