title: MySQL Orderby a number, Empty Strings (or 0's) Last
body: <p>Just asked a question pretty similar to this one...</p>
  
  <p>Currently I am doing a very basic OrderBy in my statement.</p>
  
  <pre><code>SELECT * FROM tablename WHERE visible=1 ORDER BY position ASC, id DESC
  </code></pre>
  
  <p>The problem with this is that empty string entries for 'position' are treated as 0. Therefore all entries with position as empty string appear before those with 1,2,3,4. eg:</p>
  
  <pre><code>'', '', '', 1, 2, 3, 4
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>0, 0, 0, 1, 2, 3, 4
  </code></pre>
  
  <p>Is there a way to achieve the following ordering:</p>
  
  <pre><code>1, 2, 3, 4, '', '', ''.
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>1, 2, 3, 4, 0, 0, 0.
  </code></pre>
  
  <p>I assume the solution may have some kind of replace function but I am not able to find a function which does what I am after.</p>