View Single Post
  #2 (permalink)  
Old 05-13-2006, 01:09 PM
ben ben is offline
Administrator
 
Join Date: Mar 2007
Posts: 92
ben has disabled reputation
Default 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.
Reply With Quote