Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 510DF4758F1 for ; Mon, 18 Nov 2002 02:07:02 -0500 (EST) Received: from horizon.co.za (ganesha.horizon.co.za [196.44.34.18]) by postgresql.org (Postfix) with ESMTP id 1F821476456 for ; Mon, 18 Nov 2002 02:06:56 -0500 (EST) Received: from [192.168.1.112] (helo=andy) by horizon.co.za with smtp (Exim 3.13 #1) id 18DfvJ-0002Di-00 for pgsql-php@postgresql.org; Mon, 18 Nov 2002 09:02:21 +0200 Message-ID: <001801c28ed0$f7153860$7001a8c0@horizon.co.za> From: "Andy Dunlop" To: Subject: Nested select to same tsble Date: Mon, 18 Nov 2002 09:06:05 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0015_01C28EE1.B9AB6B00" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/74 X-Sequence-Number: 1656 This is a multi-part message in MIME format. ------=_NextPart_000_0015_01C28EE1.B9AB6B00 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I hope you won't mind helping me here: (I have searched the Postgres mailin= g lists but no-one seems to have had this problem) None of the documentatio= n seems to address this: Is this legal? $sSql =3D "select glatype, gla.glacode, gladescrip, gladepr, gll.* from gll,gla where gll.glacode =3D gla.glacode and gla.glatype =3D '".strtoupper($glrowresult)."' and gll.fisyear =3D $year order by gll.glacode"; $result1 =3D pg_exec($conn, $sSql); for($i=3D0;$i
I hope you won't mind helping me here: (I = have=20 searched the Postgres mailing lists but no-one seems to have had this probl= em)=20 None of the documentation seems to address this:
 
Is this legal?
 
$sSql =3D "select glatype, gla.glacode, gl= adescrip,=20 gladepr,=20 gll.*
           =     =20 from=20 gll,gla
          &nbs= p;    =20 where gll.glacode =3D=20 gla.glacode
          =      =20 and gla.glatype =3D=20 '".strtoupper($glrowresult)."'
       = ;        =20 and gll.fisyear =3D=20 $year
           =     =20 order by gll.glacode";
        $resul= t1 =3D=20 pg_exec($conn, $sSql);
       =20 for($i=3D0;$i<pg_numrows($result1);$i++)
    &nbs= p; =20  {
          &nbs= p;    =20 $glresult =3D=20 pg_fetch_array($result1,$i);
       &= nbsp;       =20 if($glresult["glatype"]=3D=3D"FA")
      &= nbsp;        =20 {
              &= nbsp;=20     $sSql=3D"select * from=20 gll
           &n= bsp;            = ;       =20 where gll.glacode =3D=20 '".strtoupper($glresult["gladepr"])."'
     &nb= sp;            =             &nb= sp;=20 and gll.fisyear =3D $year";

The second select does not work - it g= ives no=20 error message either. I wonder if it does not like selecting a seond time f= rom=20 gll while in the loop after the first select. The idea is that some gl acco= unts=20 need to refer to other ones for a calculation to be done during this report= I am=20 trying to do.
 
Thanks
_________________________________
Andy= =20 Dunlop
mailto:andy@horizon.co.za
 
Office:   +27 (21) 975=20 2440
Cell:      +27 (82) 770=20 8749
_________________________________
------=_NextPart_000_0015_01C28EE1.B9AB6B00--