I need to sort the goods by price. I do this:

ORDER BY price ASC 

But the problem is that the sorting begins with goods with a price of 0 , although they should be at the very end.
How to implement without creating crutches in the form of additional fields?

  • products with a price of 0 must be displayed? - nueq
  • Yes, at the end of the list - 15828
  • An additional field in the SELECT based on the price = 0 and sorting by other fields is the solution and not a crutch. - Dmitry Nail

2 answers 2

You can do it like this:

 SELECT * FROM table ORDER BY price = 0 ASC, price ASC 

    decided so:

     ORDER BY IF(price > 0,1,0) DESC, price ASC