title: How to select all the hierarchy of a table with levels in PostgreSQL
body: <p>I have a problem in this moment. 
  I have a table called places with this structure:</p>
  
  <ul>
  <li>id</li>
  <li>parent_id</li>
  <li>name</li>
  </ul>
  
  <p>I want to do a selection to have all the hierarchy of this table. There's a little example of data:</p>
  
  <pre><code>(1, null, '123 Barclay St')
  (2, 1, 'Floor 1')
  (3, 1, 'Floor 2')
  (4, 1, 'Floor 3')
  (5, 2, 'Hall 1')
  (6, 2, 'Room 1')
  (7, 2, 'Room 2')
  (8, 3, 'Room 3')
  (9, null, '10 Thames St')
  </code></pre>
  
  <p>Obviously the order in the table is not this one. </p>
  
  <p>So I want to get this result with my SELECT (with the 9 rows):</p>
  
  <pre><code>123 Barclay St
     Floor 1
        Hall 1
        Room 1
        Room 2
     Floor 2
        Room 3
     Floor 3
  10 Thames St
  </code></pre>
  
  <p>And not this result (that I already know how to get) :</p>
  
  <pre><code>10 Thames St
  123 Barclay St
     Floor 1
     Floor 2
     Floor 3
        Hall 1
        Room 1
        Room 2
        Room 3
  </code></pre>
  
  <p>If you can help me, I thank you in advance.</p>