MySQL-对文本列进行排序
我有一张桌子:MySQL-对文本列进行排序,mysql,Mysql,我有一张桌子: id (int) | floor (text) ----------------------- 1 | 1 2 | 10 3 | 7 4 | Ground floor 我希望查询结果对文本列floor上的数据进行排序。有可能得到这样的结果吗 id (int) | floor (text) ----------------------- 4 | Ground floor 1 | 1 3
id (int) | floor (text)
-----------------------
1 | 1
2 | 10
3 | 7
4 | Ground floor
我希望查询结果对文本列floor
上的数据进行排序。有可能得到这样的结果吗
id (int) | floor (text)
-----------------------
4 | Ground floor
1 | 1
3 | 7
2 | 10
下面是一种使用mysql的静默转换技术并将其应用于ORDERBY子句的方法
select * from mytable
order by
case
when `floor`+0 = 0 then 0
else 1
end , `floor`+0,`floor`
或者更容易
select * from mytable
order by `floor`+0,`floor`
请参阅:您尝试过哪些sql语句?