title: Sql question: Getting Parent rows followed by child rows
body: <p>id  parent_id</p>
  
  <p>1     0</p>
  
  <p>2     0</p>
  
  <p>3     2</p>
  
  <p>4     0</p>
  
  <p>5     1</p>
  
  <p>6     0</p>
  
  <p>I need a query that will return parent rows (parent_id=0) followed by its child rows</p>
  
  <p>first parent</p>
  
  <p>all children of first parent</p>
  
  <p>second parent</p>
  
  <p>all children of second parent</p>
  
  <p>third parent</p>
  
  <p>fourth parent</p>
  
  <p>Expected result: ordered by id</p>
  
  <p>id   parent_id</p>
  
  <p>1    0 (first parent)</p>
  
  <p>5    1     (all children of first parent)</p>
  
  <p>2    0 second parent</p>
  
  <p>3    2     (all children of second parent)</p>
  
  <p>4    0 third parent</p>
  
  <p>6    0 fourth parent</p>
  
  <p>I can use union of parents followed by all childs
  But that gives me parents first then the children.
  I need parent and immediately its children.</p>
  
  <p>Anyone can help?</p>