Re: GetHierarchy - Mailing list pgsql-general

From Alban Hertroys
Subject Re: GetHierarchy
Date
Msg-id 61A3BB1A-6B97-4C8C-8F8F-D25305C7CBB4@gmail.com
Whole thread Raw
In response to GetHierarchy  (bhanu udaya <udayabhanu1984@hotmail.com>)
List pgsql-general
On Mar 1, 2013, at 3:18, bhanu udaya <udayabhanu1984@hotmail.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
needparent 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.



pgsql-general by date:

Previous
From: bhanu udaya
Date:
Subject: GetHierarchy
Next
From: Raymond O'Donnell
Date:
Subject: Re: Poor performance when using a window function in a view