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

Re: querying from 3 tables

From: Francesco Piccinini <francesco(dot)piccinini(at)st(dot)com>
To: ryanne(dot)cruz(at)up(dot)edu(dot)ph
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: querying from 3 tables
Date: 2003-03-07 06:20:01
Message-ID: 3E683A10.D56B155@st.com (view raw or flat)
Thread:
Lists: pgsql-php
What about the following:

select a.brgyd,a.households,b.munprovid,c.geom
from table1 a, table2 b, table3 c
where a.esourceid=$esourceid and
             a.brgyd=b.brgyd and
             b.munprovid=c.geom ;


Bye, Francesco

ryanne(dot)cruz(at)up(dot)edu(dot)ph wrote:

>
> hi list.
>
> i have 3 tables with the following columns:
>
> table1: esourceid (primary key), brgyid, households
> table2: brgyid (primary key), munprovid
> table3: munprovid (primary key), geom
>
> i am given the esourceid and i need to query the brgyid and the households of
> a particular esourceid: query1="select brgyid, households from table1 where
> esourceid=$esourceid;"
>
> the resulting brgyid will then be used to query for the munprovid in table2:
> query2="select munprovid from table2 where brgyid=(query1);"
>
> the resulting munprovid will then be used to query for  the geom column:
> "select geom from table3 where munprovid=(query2);"
>
> my question is, how do i do this? any ideas?
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster


In response to

pgsql-php by date

Next:From: Francesco PiccininiDate: 2003-03-07 06:22:44
Subject: Re: querying from 3 tables
Previous:From: Christopher Kings-LynneDate: 2003-03-07 05:30:49
Subject: Re: querying from 3 tables

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