title: How to return starting and end point of a path in a hierarchical structure
body: <p>I have a table that looks like that</p>
  
  <pre><code>---------------------------
  | id1 | id2 | col1 | col2 |
  +-----+-----+------+------+
  |  1  |  1  |  a   |  b   |
  |-----+-----+------+------|
  |  1  |  2  |  b   |  c   |
  |-----+-----+------+------|
  |  5  |  1  |  d   |  f   |
  ---------------------------
  </code></pre>
  
  <p>The idea is that the table stores paths: a->b->c and d->f. What I want is a query that will return a->c and d->f.</p>