I have table products
with column price
.
It have rows with values:
2
0
4
5
0
3
1
What params with select
should I use to get result like this:
1
2
3
4
5
0
0
I have table products
with column price
.
It have rows with values:
2
0
4
5
0
3
1
What params with select
should I use to get result like this:
1
2
3
4
5
0
0
You could first order by 0 & then rest
SELECT * FROM <table> ORDER BY CASE WHEN price = 0 THEN 1 ELSE 0 END,price
Try it
SELECT *
FROM test
ORDER BY IF(price=0,999999999,price)
SQL Fiddle - http://sqlfiddle.com/#!9/98f02/2