title: MySQL order by value1 unless value1 < 0, then order by value2
body: <p>I have a script that runs 2 rather slow SQL queries that are almost identical. One selects from the database records that are supposed to be "featured" on a page, i.e. they come first. Another selects from the database the regular records. Each query takes approximately 0.3 seconds, and since both run at the same time, I lose 0.6 seconds on them. So I was wondering if it would be possible to combine these queries. Here is what they look like:</p>
  
  <pre><code>SELECT * FROM records WHERE [other where conditions] AND featured&gt;=$timestamp ORDER BY featured DESC
  
  SELECT * FROM records WHERE [other where conditions] AND featured&lt;$timestamp ORDER BY created DESC
  </code></pre>
  
  <p>What I have labeled [other where conditions] is identical in both cases. So what I essentially need to do is:</p>
  
  <pre><code>SELECT * FROM records WHERE [other where conditions] ORDER BY featured DESC UNLESS featured &lt; $timestamp, created DESC
  </code></pre>
  
  <p>Except I don't know how to tell MySQL "ORDER BY ... UNLESS".</p>