按数字排序,其中可以是连字符-mysql
我有一个疑问按数字排序,其中可以是连字符-mysql,mysql,sql-order-by,Mysql,Sql Order By,我有一个疑问 select * from table order by numbers asc 编号为:32、-11、76、 我得到的是-,-,11,32,76(开头连字符) 我应该在查询中更改什么,以便在结尾处获得连字符?您将数字存储为varchar(),当您有1,11,9,5…等数据时,您会遇到更多问题,并且排序将有1,11,5,9… 以下是您可以如何管理它 select * from table_name order by case when numbers ='-' then 2 e
select * from table order by numbers asc
编号为:32、-11、76、
我得到的是-,-,11,32,76
(开头连字符)
我应该在查询中更改什么,以便在结尾处获得连字符?您将数字存储为varchar(),当您有
1,11,9,5…
等数据时,您会遇到更多问题,并且排序将有1,11,5,9…
以下是您可以如何管理它
select * from table_name
order by case when numbers ='-' then 2 else 1 end,numbers+0 ;
您将数字存储为varchar(),当您有
1,11,9,5…
等数据时,您会遇到更多的问题,并且排序将有1,11,5,9…
以下是您可以如何管理它
select * from table_name
order by case when numbers ='-' then 2 else 1 end,numbers+0 ;
您将数字存储为varchar(),当您有
1,11,9,5…
等数据时,您会遇到更多的问题,并且排序将有1,11,5,9…
以下是您可以如何管理它
select * from table_name
order by case when numbers ='-' then 2 else 1 end,numbers+0 ;
您将数字存储为varchar(),当您有
1,11,9,5…
等数据时,您会遇到更多的问题,并且排序将有1,11,5,9…
以下是您可以如何管理它
select * from table_name
order by case when numbers ='-' then 2 else 1 end,numbers+0 ;
首先,我尝试使用条件流和类型转换进行排序
SELECT * FROM `table` ORDER BY numbers = '-', numbers+0 asc
如果您想要相反的结果,请否定条件流
SELECT * FROM `table` ORDER BY numbers != '-', numbers+0 asc
首先,我尝试使用条件流和类型转换进行排序
SELECT * FROM `table` ORDER BY numbers = '-', numbers+0 asc
如果您想要相反的结果,请否定条件流
SELECT * FROM `table` ORDER BY numbers != '-', numbers+0 asc
首先,我尝试使用条件流和类型转换进行排序
SELECT * FROM `table` ORDER BY numbers = '-', numbers+0 asc
如果您想要相反的结果,请否定条件流
SELECT * FROM `table` ORDER BY numbers != '-', numbers+0 asc
首先,我尝试使用条件流和类型转换进行排序
SELECT * FROM `table` ORDER BY numbers = '-', numbers+0 asc
如果您想要相反的结果,请否定条件流
SELECT * FROM `table` ORDER BY numbers != '-', numbers+0 asc