Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL-对文本列进行排序_Mysql - Fatal编程技术网

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语句?