问题
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
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
etc..
But that 10 needs to be after the 9, not before the 1, how is this possible?
Thank you, Kind regards
回答1:
SELECT
CAST(title AS UNSIGNED INTEGER) AS ORDER_FIELD
,title
ORDER BY
ORDER_FIELD ASC
来源:https://stackoverflow.com/questions/12601498/mysql-order-number-character-combined