pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: querying from 3 tables
5+ messages / 3 participants
[nested] [flat]
* Re: querying from 3 tables
@ 2003-03-07 05:11 ryanne cruz <ryanne.cruz@up.edu.ph>
0 siblings, 4 replies; 5+ messages in thread
From: ryanne cruz @ 2003-03-07 05:11 UTC (permalink / raw)
To: pgsql-php
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?
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: querying from 3 tables
@ 2003-03-07 05:30 Christopher Kings-Lynne <chriskl@familyhealth.com.au>
parent: ryanne cruz <ryanne.cruz@up.edu.ph>
3 siblings, 0 replies; 5+ messages in thread
From: Christopher Kings-Lynne @ 2003-03-07 05:30 UTC (permalink / raw)
To: ryanne cruz <ryanne.cruz@up.edu.ph>; pgsql-php
> 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?
You can do this:
select geom from table3 where munprovid=(select munprovid from table2 where
brgyid=(select brgyid, households from table1 where esourceid=$esourceid));
Chris
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: querying from 3 tables
@ 2003-03-07 06:20 Francesco Piccinini <francesco.piccinini@st.com>
parent: ryanne cruz <ryanne.cruz@up.edu.ph>
3 siblings, 0 replies; 5+ messages in thread
From: Francesco Piccinini @ 2003-03-07 06:20 UTC (permalink / raw)
To: ryanne.cruz@up.edu.ph; +Cc: 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.cruz@up.edu.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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: querying from 3 tables
@ 2003-03-07 06:22 Francesco Piccinini <francesco.piccinini@st.com>
parent: ryanne cruz <ryanne.cruz@up.edu.ph>
3 siblings, 0 replies; 5+ messages in thread
From: Francesco Piccinini @ 2003-03-07 06:22 UTC (permalink / raw)
To: ryanne.cruz@up.edu.ph; 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.cruz@up.edu.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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: querying from 3 tables
@ 2003-03-07 06:25 Francesco Piccinini <francesco.piccinini@st.com>
parent: ryanne cruz <ryanne.cruz@up.edu.ph>
3 siblings, 0 replies; 5+ messages in thread
From: Francesco Piccinini @ 2003-03-07 06:25 UTC (permalink / raw)
To: ryanne.cruz@up.edu.ph; pgsql-php
Sorry ...... this is the rigth query
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.munprovid ;
Bye, Francesco
ryanne.cruz@up.edu.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
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2003-03-07 06:25 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-07 05:11 Re: querying from 3 tables ryanne cruz <ryanne.cruz@up.edu.ph>
2003-03-07 05:30 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
2003-03-07 06:20 ` Francesco Piccinini <francesco.piccinini@st.com>
2003-03-07 06:22 ` Francesco Piccinini <francesco.piccinini@st.com>
2003-03-07 06:25 ` Francesco Piccinini <francesco.piccinini@st.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox