X-Original-To: pgsql-php@postgresql.org Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by postgresql.org (Postfix) with ESMTP id 669A1477182 for ; Fri, 7 Mar 2003 01:23:29 -0500 (EST) Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with SMTP id B792448F7; Fri, 7 Mar 2003 06:23:28 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 0) id 70A46636B; Fri, 7 Mar 2003 06:23:27 +0000 (GMT) Received: from agx003.agr.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 753F31848; Fri, 7 Mar 2003 06:23:27 +0000 (GMT) Received: from st.com (pic.rdd.agr.st.com [164.130.35.126]) by agx003.agr.st.com (8.9.3 (PHNE_24419)/8.9.3) with ESMTP id HAA03443; Fri, 7 Mar 2003 07:23:26 +0100 (MET) Message-ID: <3E683AB4.2D00DFDE@st.com> Date: Fri, 07 Mar 2003 07:22:44 +0100 From: Francesco Piccinini X-Mailer: Mozilla 4.76 [en] (X11; U; SunOS 5.8 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: ryanne.cruz@up.edu.ph, pgsql-php@postgresql.org Subject: Re: querying from 3 tables References: <1047013864.3e6829e837bdb@mail.up.edu.ph> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/6 X-Sequence-Number: 1918 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