Home MySQL中对字符串类型字段进行数字值排序
Post
Cancel

MySQL中对字符串类型字段进行数字值排序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- 方式一
SELECT
    * 
FROM
    TABLE_TEST 
WHERE
    STATUS = '1' 
ORDER BY
    ORDER_NUMBER + 0 DESC
        
        
-- 方式二        
SELECT
    * 
FROM
    TABLE_TEST 
WHERE
    STATUS = '1' 
ORDER BY
    ORDER_NUMBER * 1 DESC
This post is licensed under CC BY 4.0 by the author.