MySQL answer.
Re: How to order rows in a predefined pattern?
This is actually a problem I had when working on the articles module for this site.
I wanted the "README" and the "FEEDBACK" articles to always be at the top of the list and the other articles ordered in descending order.
This is what I did:
[sql]
SELECT * FROM articles ORDER BY id = 1 DESC, id = 2 DESC, id DESC[/sql]
I also tried:
[sql]
SELECT * FROM articles ORDER BY id IN (1,2) DESC, id DESC[/sql]
but that would place article 2 in front of article 1.
|