title: Climbing a Parent/Child Database Relationship in Postgres
body: <p>We have the following example table (actually taken from another example here on stackoverflow...)  </p>
  
  <pre><code>CREATE TABLE example (
    id integer primary key,
    name char(200),
    parentid integer,
    value integer);
  </code></pre>
  
  <p>And given a specific child we want to get the top Parent.</p>
  
  <p>I know of the tablefunc connectby function but that is for getting a parents children.</p>
  
  <p>But, I'm interested in the other direction, given a child what is its top parent?  What type of query would I try and use?</p>
  
  <p>Any friendly advice is appreciated.</p>