title: SQL query for parent-child chain
body: <p>I have a single table that can refer to one other member in the table as a parent.  That parent could also refer to one other row as its parent...and so on.</p>
  
  <pre><code>id     col1     col2    parentID
  1      foo      bar       NULL
  2      blah     boo       1
  3      fob      far       2
  4      wob      lob       NULL
  </code></pre>
  
  <p>I would like to return the chain given an id.  So if the id were 3 I would return row 3, row 2 and row 1.  If id was 2 I would return row 2 and row 1.  If the id were 1 or 4 I would just return that row.</p>
  
  <p>thank you</p>