Re: [HACKERS] Reg: Nested query

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Vignesh Raaj <vigneshraaj(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [HACKERS] Reg: Nested query
Date: 2008-12-01 19:38:05
Message-ID: 20081201193805.GH4459@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support pgsql-general pgsql-hackers pgsql-sql pgsql-www

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

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Raymond O'Donnell 2008-12-01 22:33:14 Re: [pgsql-www] Reg: Nested query
Previous Message Vignesh Raaj 2008-12-01 18:39:23 Reg: Nested query

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-12-01 19:51:53 Re: Detecting changes to certain fields in 'before update' trigger functions
Previous Message Tom Lane 2008-12-01 18:53:56 Re: Trigger before delete does fire before, but delete doesn't not happen

Browse pgsql-hackers by date

  From Date Subject
Next Message Emmanuel Cecchet 2008-12-01 20:50:42 Re: Transactions and temp tables
Previous Message Greg Sabino Mullane 2008-12-01 19:31:49 Re: Statement-level triggers and inheritance

Browse pgsql-sql by date

  From Date Subject
Next Message Raymond O'Donnell 2008-12-01 22:33:14 Re: [pgsql-www] Reg: Nested query
Previous Message Vignesh Raaj 2008-12-01 18:39:23 Reg: Nested query

Browse pgsql-www by date

  From Date Subject
Next Message Raymond O'Donnell 2008-12-01 22:33:14 Re: [pgsql-www] Reg: Nested query
Previous Message Vignesh Raaj 2008-12-01 18:39:23 Reg: Nested query