How to get the top most parent in PostgreSQL

Posted by wereach on Stack Overflow See other posts from Stack Overflow or by wereach
Published on 2010-05-18T08:47:41Z Indexed on 2010/05/18 8:50 UTC
Read the original article Hit count: 155

Filed under:

I have a tree structure table with columns: id,parent,name. Given a tree A->B->C, how could i get the most top parent A's ID according to C's ID? Especially how to write SQL with "with recursive"? Thanks!

© Stack Overflow or respective owner

Related posts about postgresql