Sort MySQL results by preference

2

I have a produtos table where if there is the primary column id , I want to select products with the probable name of "% TV%" however I want it to be ordered DESC normally, however I want it some IDS come first than others, the IDS that are in the promotion, for example 5, 4 respectively.

In this example, the result order (by ID) should be: 5, 4, e depois os outros, como 1, 2, 3, 6 ...

id | name     |
---------------
 1 | tv       |   
 2 | core     |   
 3 | tv other |   
 4 | tv board |   
 5 | apple TV |   
 6 | core     |   
    
asked by anonymous 29.07.2016 / 16:38

1 answer

4

I think this solves your problem:

SELECT *
FROM produtos
ORDER BY (id IN (5,4)) DESC, id
    
29.07.2016 / 17:11