title: Selecting records in order of parent id
body: <p>Simple question.. just can't get the result set in the order I need :p</p>
  
  <p>I have a table "categories"</p>
  
  <pre><code>id    | name     | parent
  1       apple      0
  2       macintosh  1
  3       atari      0
  4       st         3
  5       lisa       1
  </code></pre>
  
  <p>I'm trying to select get the following result set:</p>
  
  <pre><code>1   apple      0
  5   lisa       1
  2   macintosh  1
  3   atari      0
  4   st         3
  </code></pre>
  
  <p>So in other words  I want all columns of all rows, where rows with parents are immediately after their parent row and all are sorted alphabetically.</p>
  
  <pre><code>parent a
   child a
   child b
  parent b
   child a
  </code></pre>
  
  <p>The query I'm using now doesn't correctly re-order the rows after their parents</p>
  
  <pre><code>SELECT a.*, b.* FROM categories a RIGHT JOIN categories b ON b.parent = a.id
  </code></pre>