Re: GetHierarchy

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: bhanu udaya <udayabhanu1984(at)hotmail(dot)com>
Cc: Kevin Grittner <kgrittn(at)mail(dot)com>, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, Chris Travers <chris(dot)travers(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>
Subject: Re: GetHierarchy
Date: 2013-03-01 08:03:07
Message-ID: 61A3BB1A-6B97-4C8C-8F8F-D25305C7CBB4@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support pgsql-general

On Mar 1, 2013, at 3:18, bhanu udaya <udayabhanu1984(at)hotmail(dot)com> 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.

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Michael Shapiro 2013-03-02 17:46:45 object browser collapses
Previous Message Craig Ringer 2013-03-01 04:33:04 Re: GetHierarchy

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2013-03-01 09:21:20 Re: Poor performance when using a window function in a view
Previous Message Craig Ringer 2013-03-01 04:33:04 Re: GetHierarchy