在MySQL中,我需要ORDER BY CAST(varchar AS unsigned),但是,我还需要命令" 0"最后。我有可能做到这一点吗? 例如:
"1"
"10"
"0"
"2"
结果应该是
"1"
"2"
"10"
"0"
答案 0 :(得分:1)
ORDER BY col = '0', CAST(col AS unsigned)
col = '0'
如果不是0
,则为1
,如果是<div>
,则它将首先排序所有非零值。然后它会在这两组中按数字排序。