mysql命令号/字符组合 [英] Mysql order number / character combined
本文介绍了mysql命令号/字符组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在产品名称字段中有一个 SQL 表,其中包含以下值:
I have a SQL table with in a product-name field with the following values:
10b
9b
8b
7b
6b
5b
4b
3b
2b
1b
这些需要从 1 到 10 排序,但是由于某种原因,当我选择以下顺序时:ORDER BY title ASC
,然后我得到:
These needs to be ordered from 1 to 10, but for some reason when i select with the following order: ORDER BY title ASC
, then i get:
10b
1b
2b
3b
4b
等等.
但是那个 10 需要在 9 之后,而不是 1 之前,这怎么可能?
But that 10 needs to be after the 9, not before the 1, how is this possible?
谢谢,亲切的问候
推荐答案
SELECT
CAST(title AS UNSIGNED INTEGER) AS ORDER_FIELD
,title
ORDER BY
ORDER_FIELD ASC
这篇关于mysql命令号/字符组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文