There is a table with content:
+------+-------+----------+ | name | price | quantity | +------+-------+----------+ | alip | 10 | 0 | +------+-------+----------+ | mime | 200 | 0 | +------+-------+----------+ | vini | 70 | 1 | +------+-------+----------+ | simi | 30 | 10 | +------+-------+----------+ Need to sort in
+------+-------+----------+ | name | price | quantity | +------+-------+----------+ | simi | 30 | 10 | +------+-------+----------+ | vini | 70 | 1 | +------+-------+----------+ | alip | 10 | 0 | +------+-------+----------+ | mime | 200 | 0 | +------+-------+----------+ That is, the sample is first sampled, if the field is less than one, then it will go to love after the field with the number greater than zero. And then all products must be sorted by price.
I do this:
SELECT * FROM (SELECT * FROM `exp` ORDER BY `quantity` ASC) a ORDER BY `price` ASC Or
SELECT * FROM (SELECT * FROM `exp` WHERE quantity > 0 ORDER BY `price` ASC) a, (SELECT * FROM `exp` WHERE quantity < 1 ORDER BY `price` ASC) b But of course everything goes wrong. I do not understand how to make the correct request.
Example: http://sqlfiddle.com/#!2/7ebf1/8
expORDER BYquantity