title: MySQL ORDER BY depending on CASE order ASC or DESC
body: <p>I want based on a value queried from another table order ASC or DESC.</p>
  
  <p>So something like this:</p>
  
  <pre><code>SELECT *
  FROM table
  ORDER BY 
      CASE (SELECT sorting from table2 WHERE table2.id = ?)
          WHEN 1 THEN table.date ASC END 
          WHEN 0 THEN table.date DESC END
      END
  </code></pre>
  
  <p>Is anything like that available in MySQL?</p>
  
  <p>I've seen for MS-SQL Server some solution: <a href="https://stackoverflow.com/questions/4993229/how-to-order-2-sql-fields-in-asc-and-desc-dynamically">how to order 2 SQL Fields in asc and desc dynamically</a></p>
  
  <p><strong>EDIT</strong>: I just saw I made a mistake in the description, fixed.</p>