Skip site navigation (1) Skip section navigation (2)

Reg: Nested query

From: "Vignesh Raaj" <vigneshraaj(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-www(at)postgresql(dot)org, ukpug(at)postgresql(dot)org, pgadmin-support(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Reg: Nested query
Date: 2008-12-01 18:39:23
Message-ID: ed6e9ae90812011039u6d1964baqdf01b72d222d8cab@mail.gmail.com (view raw or flat)
Thread:
Lists: pgadmin-supportpgsql-generalpgsql-hackerspgsql-sqlpgsql-www
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"

Responses

pgsql-general by date

Next:From: Tom LaneDate: 2008-12-01 18:53:56
Subject: Re: Trigger before delete does fire before, but delete doesn't not happen
Previous:From: Malinka RellikwodahsDate: 2008-12-01 18:21:00
Subject: Re: db backup script in gentoo

pgsql-www by date

Next:From: Alvaro HerreraDate: 2008-12-01 19:38:05
Subject: Re: [HACKERS] Reg: Nested query
Previous:From: Guido BarosioDate: 2008-12-01 16:10:49
Subject: Re: Who is moderating the news?

pgsql-sql by date

Next:From: Alvaro HerreraDate: 2008-12-01 19:38:05
Subject: Re: [HACKERS] Reg: Nested query
Previous:From: Steve CrawfordDate: 2008-12-01 17:18:50
Subject: Re: wired behaviour

pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2008-12-01 18:46:41
Subject: Re: New to_timestamp implementation is pretty strict
Previous:From: Greg SmithDate: 2008-12-01 17:54:43
Subject: Re: Simple postgresql.conf wizard

pgadmin-support by date

Next:From: Alvaro HerreraDate: 2008-12-01 19:38:05
Subject: Re: [HACKERS] Reg: Nested query
Previous:From: Stefan KellerDate: 2008-11-30 20:09:10
Subject: Re: Need some informations...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group