title: ORDER BY condition
body: <p>I would like to retrieve an ordered query result, but I need to have some specific row(s) to be in front of the list. Something like here on Stack Overflow, in the list of answers the right answer is always the first one.</p>
  
  <p>Assumed I need to have the rows with IDs 1,2,3 to be the head, the rest sorted by a date field, is it possible to do something like:</p>
  
  <pre><code>SELECT * FROM foo ORDER BY id IN (1,2,3), created_date
  </code></pre>
  
  <p>If not what is more efficient? There will be many rows!</p>
  
  <pre><code>SELECT *, 0 AS head FROM foo WHERE id IN (1,2,3) 
  UNION
  SELECT *, 1 AS head FROM foo WHERE id NOT IN (1,2,3)
  ORDER BY head, created_date
  </code></pre>
  
  <p>or</p>
  
  <pre><code>SELECT *, IF(id IN (1,2,3), 0, 1) AS head
  ORDER BY head, created_date
  </code></pre>
  
  <p>(I use MySQL now, but I'm interested in any other SQL solution.)</p>