Answer the question
In order to leave comments, you need to log in
How to sort by multiple fields?
There is a table with the fields id, shopID, description, active, vip.
You need to display 9 records sorted by id, but so that records with vip=1 are first, and records with shopID are also first, but after vip.
this query does not work correctly:
SELECT id, shopID, description FROM shops WHERE active=1 ORDER BY id, vip, FIELD(shopID, 3) DESC LIMIT 0, 9
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question