K
K
Kirill Petrov2015-09-02 16:18:51
PHP
Kirill Petrov, 2015-09-02 16:18:51

How to compose a query in MySQL to sort by value?

There is a sign:
1ade787b12cf41e49db9fe6853a91593.png
Tell me, how to make a query so that there would be sorting by price in ascending order, but the elements with qt = 0 should be displayed last?
That is, in the end I want to get the following result:
65d5596a307746f896ccd73aa7e03930.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2015-09-02
@Recosh

try

SELECT * FROM TBL_MYTABLE WHERE qt > '0' ORDER BY price
UNION  SELECT * FROM TBL_MYTABLE WHERE qt = '0' ORDER BY price

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question