Reg: Nested query
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...
Table "person"
Column | Type |
Modifiers
------------+-----------------------+----------------------------------------------------
pid | bigint | not null default
nextval('"person_pid_seq"'::text)
first_name | character varying(50) |
surname | character varying(50) |
dob | date |
Primary key: person_pkey
Table "parent_of"
Column | Type | Modifiers
-----------+---------+-----------
person_id | integer |
parent_id | integer |
so if i give first_name of person = ????, then i have get all the parent
ids. I tried nested query but tat resulted in 1 level parent alone.
i want to get all parent id... please help me..!
Reagrds,
Vignesh
--
"A man who believes in himself and not circumstances is the real winner"
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
On 01/12/2008 18:39, Vignesh Raaj wrote:
Can anyone please help in getting a solution...
Cross-posting to lots of inappropriate lists is not going to endear you
to many people, and is going to decrease, not increase, your chance of
getting an answer.
You should post to -general only with this query, as ISTM that this is
most appropriate for your query.
Ray.
------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------