title: Get results from a MySQL database recursively
body: <p>Consider the following:</p>
  
  <p><code>Table - id, parentid</code></p>
  
  <p>What I'd like to do, is I'd like to pull all the children (not only direct children, but all of them, i.e. children of children of children etc.) of a specific parent.</p>
  
  <p>So let's say the table contains the following row: <code>(2, 1), (3, 1), (4, 2), (5, 4)</code></p>
  
  <p>Then for parentid = 1, the table would return ids 2, 3, 4 AND 5.</p>
  
  <p>Is this possible?</p>
  
  <p>If not (and I guess it's indeed not possible), what are my options?</p>
  
  <p>I really don't want to use dozens of queries...</p>
  
  <p>P.S. I can't change the database structure.</p>
  
  <p>Also, as there might be hundreds of thousands of records in the table, I can pull them all and do the whole thing using PHP instead.</p>