Re: [HACKERS] Reg: Nested query - Mailing list pgsql-sql

From Alvaro Herrera
Subject Re: [HACKERS] Reg: Nested query
Date
Msg-id 20081201193805.GH4459@alvh.no-ip.org
Whole thread Raw
List pgsql-sql
Hi,

It's poor manners to crosspost questions to such a huge number of lists,
particularly when there is one among them that perfectly suits your
question.

Vignesh Raaj escribió:
> Can anyone please help in getting a solution...
> I have two table, 1 contains all details of a person with person id as
> primary key.
> the other table has person id and parent id both referring to person table
> person id.
> My query is i have to get all the parents of a given person name.
> Please help me in finding a query solution...

You can't do it short of writing a function that recurses, or using such
tricks as contrib/ltree.  In the upcoming 8.4 version you will be able
to write queries with the WITH RECURSIVE construct to handle this
directly in SQL.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-sql by date:

Previous
From: Steve Crawford
Date:
Subject: Re: wired behaviour
Next
From: Milan Oparnica
Date:
Subject: Re: JOIN results of refcursor functions