X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 16B16528E6 for ; Fri, 12 Aug 2005 01:03:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07266-07 for ; Fri, 12 Aug 2005 04:03:27 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7CD2F528D1 for ; Fri, 12 Aug 2005 01:03:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7C43QcQ025509; Fri, 12 Aug 2005 00:03:26 -0400 (EDT) To: Louise Catherine Cc: pgsql-sql@postgresql.org Subject: Re: about subselect In-reply-to: <20050812033830.80532.qmail@web33414.mail.mud.yahoo.com> References: <20050812033830.80532.qmail@web33414.mail.mud.yahoo.com> Comments: In-reply-to Louise Catherine message dated "Thu, 11 Aug 2005 20:38:30 -0700" Date: Fri, 12 Aug 2005 00:03:26 -0400 Message-ID: <25508.1123819406@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/64 X-Sequence-Number: 22292 Louise Catherine writes: > I make a subquery test at postgresql > 7.3.3 and postgresql 8.0.3. > I found that postgresql 8.0.3 can't do this, > while at postgresql 7.0.3 it works quite well : 7.3 says this: NOTICE: Adding missing FROM-clause entry in subquery for table "temp_hasil2" which means that the query is invalid according to the SQL spec. Later versions are just being tougher about enforcing the spec. If you are happy with 7.3's interpretation of what the query means, try adding > Update Temp_hasil2 Set KdPT = A.PTCD, > KdLjr = A.LKRJACD > From (Select A38.NIK,A01.ptcd,A38.Lkrjacd > From AM382 A38 > inner join > ap012 A01 on A38.nojob = A01.nojob > Where A38.tglavd = > (select max(B38.tglavd) from am382 B38, Temp_hasil2 ^^^^^^^^^^^^^ > where A38.nik = B38.nik > and B38.tglavd <= Temp_hasil2.Tanggal) > And A01.tglavd = > (select max(B01.tglavd) from ap012 B01 > where A01.nojob = B01.nojob > and B01.tglavd <= A38.tglavd) > )A > Where Temp_hasil2.NIK = A.NIK; regards, tom lane