user3256212 user3256212 - 1 year ago 74
MySQL Question

Write query for positive value in ascending order and negative value in

I have mysql table that looks like below :
enter image description here

In this table there are minus and plus value. I wants all record in dropdown in a format like.

I need to show first as zero than minus value in descending order and positive value in acsending order. So what query should I have to write?

For example :

0.00
-1
-2
...
...
...
1
2
3
...
...
...

Answer Source

Use 3 querys and join the results together by using union

select * from sph where value = 0
union
select * from sph where value < 0 order by value desc
union
select * from sph where value > 0 order by value asc