MySQL按字母顺序-数字 [英] MySQL order by alphabet - numeric

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

问题描述

有没有办法像这样在MySQL中对元素进行排序:

Is there any way to sort Elements in MySQL like this:

元素:

  1. 城市1
  2. 城市2
  3. 城市10
  4. 城市1a

当我执行ORDER BY时,列表看起来是这样的:

When i do the ORDER BY the list looks this way:

  1. 城市1
  2. 城市1a
  3. 城市10
  4. 城市2

因为所有答案都不符合我的特殊问题,所以我编辑了我的问题. 在数字后面也有带字符的Elements.观看示例

Because all answer did not match to my special problem i edit my question. There are also Elements with Chars behind the numbers. Watch the example

推荐答案

尝试一下技巧-'ORDER BY column_name + 1',例如:

Try this trick - 'ORDER BY column_name+1', e.g.:

SELECT * FROM element
ORDER BY column_name+1;

这篇关于MySQL按字母顺序-数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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