Answer the question
In order to leave comments, you need to log in
MySQL. How to make a selection / sorting?
Hello! Please tell me how to organize the sample.
There is a table (for example)
id name upc
1 a1 new
2 a2 new
3 a3 old
4 a4 action
5 a5 old
When selecting all records, how to do it correctly so that those records with upc = old are displayed first?
Answer the question
In order to leave comments, you need to log in
You can even sort by multiple values:
SELECT * FROM table ORDER BY FIELD (upc, 'old', 'new', 'action') DESC
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question