Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.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_Sql_Sorting - Fatal编程技术网

树输出mysql

树输出mysql,mysql,sql,sorting,Mysql,Sql,Sorting,我有一个专栏 1 11 12 2 21 我想按描述顺序显示列,如下所示 2 1 11 12 13 也就是说,我想按个位数对列进行排序 描述。 我怎么能做到? DB-mysql试试这个: select col from my_table order by (case when col = 2 then 0 else col end) 试试这个: select col from my_table order by (case when col = 2 then

我有一个专栏

1
11
12
2
21
我想按描述顺序显示列,如下所示

   2
   1
   11
   12
   13 
也就是说,我想按个位数对列进行排序 描述。 我怎么能做到? DB-mysql

试试这个:

select col from my_table order by (case when col = 2 then 0 else col end)
试试这个:

select col from my_table order by (case when col = 2 then 0 else col end)
这对你有帮助

这对你有帮助


只需将值转换为字符串:

order by cast(col as varchar) desc

只需将值转换为字符串:

order by cast(col as varchar) desc

输出不起作用,例如g1 | g | f | e | d | c1 | c | b11 | b1 | b}我不确定你的评论指的是什么。这个答案是针对你所问的问题的。ouput | g1 | g | f | e | d | c1 | c | b11 | b1 | b}的例子不起作用。我不确定你的评论指的是什么。这个答案是针对你问的问题的。好主意,我会试试。好主意,我会试试