title: SQL sorting by two columns, ignore null
body: <p>I have a table with two columns like so:</p>
  
  <ol>
  <li>price (varchar)</li>
  <li>discount (varchar)</li>
  </ol>
  
  <p>These two hold the price and discount for all of the products in my database. When users view the products, I have multiple sorting modes available, one of which is <code>Sort by price: low to high</code>. In order to do this, I have the following code:</p>
  
  <pre><code>$stmt = $link-&gt;prepare("SELECT ... ORDER BY `discount` ASC, `price` ASC, `title` ASC");
  </code></pre>
  
  <p>This works fine for all rows where <code>discount</code> is defined, but in rows where <code>discount</code> is empty, they are sorted above the others, regardless of the value of <code>price</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>id|price|discount
  -----------------
   1|20   |10
   2|25   |10
   3|15   |
   4|15   |
  </code></pre>
  
  <p>Will echo out in the order:</p>
  
  <pre><code>3, 4, 1, 2
  </code></pre>
  
  <hr>
  
  <p>How can I rewrite this statement to sort by <code>price</code> when <code>discount</code> has no value?</p>