On Mar 1, 2013, at 3:18, bhanu udaya <udayabhanu1984@xxxxxxxxxxx> wrote: > I need a query to retrieve all the n level hierarchy when a Child node_id is passed. For example; if I pass 7, then i need parent nodes as below: I want to achive this in postgres database (version 9.2) without connect by prior. > > 3 5 > 5 6 > 6 7 > > Any reply on this is great help. You're probably looking for recursive common table expressions: http://www.postgresql.org/docs/9.2/static/queries-with.html Alban Hertroys -- If you can't see the forest for the trees, cut the trees and you'll find there is no forest. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general