title: SQL query for nested records
body: <p>Given records within a table have parents within the same table and those parents have their own parents, what query will get me the records for all parents of a requested record provided that different records can have different number of parents.</p>
  
  <p>Example: I have id of record 4 and want to get all the parent records (1,2,3). Of course I can get record 4, see who is the parent and go get record 3, see who's the parent and go get record 2, until the record I get has no parents, but is there a single query that can get me all the records?</p>
  
  <pre><code>Example Table:
  ID | Type | Parent ID
  ----------------------------
  1  |Master|
  2  |Sub 1 | 1
  3  |Sub 2 | 2
  4  |Sub 3 | 3
  5  |Master| 
  6  |Sub 1 | 5
  </code></pre>