Обсуждение: Reg: Nested query

Поиск
Список
Период
Сортировка

Reg: Nested query

От
"Vignesh Raaj"
Дата:
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"