X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 466D8D1CAE1 for ; Tue, 3 Feb 2004 06:33:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 69138-03 for ; Tue, 3 Feb 2004 02:33:26 -0400 (AST) Received: from serwer.skawsoft.com.pl (skawina.eu.org [80.48.213.66]) by svr1.postgresql.org (Postfix) with ESMTP id E27D2D1B83D for ; Tue, 3 Feb 2004 02:33:21 -0400 (AST) Received: from klaster.net (core-1.citynet.pl [80.48.135.14]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 8D0492B3CB; Tue, 3 Feb 2004 07:33:00 +0100 (CET) Message-ID: <401F412B.5090802@klaster.net> Date: Tue, 03 Feb 2004 07:35:23 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.6b) Gecko/20031208 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Russell Shaw , Lista dyskusyjna pgsql-sql Subject: Re: Outer join References: <401F3F7F.7020802@iprimus.com.au> In-Reply-To: <401F3F7F.7020802@iprimus.com.au> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/27 X-Sequence-Number: 16718 Dnia 2004-02-03 07:28, Użytkownik Russell Shaw napisał: > Hi, > I'm using postgresql 7.3.4 on debian. I get bad results > from a two-table left outer join. > > First table: select * from descriptions; > > desc_id | description > ---------+------------- > 909097 | cap > 107890 | resis > 223940 | ic > 447652 | electro > (4 rows) > > > Second table: select * from parts; > > part_id | desc_id | mounting | man_id > ---------+---------+----------+-------- > 2 | 107890 | SMD | 7 > 1 | 909097 | LEADED | 1 > 3 | 223940 | LEADED | 8 > (3 rows) > > > Join: > SELECT parts.*, d.description, d.desc_id FROM parts p LEFT OUTER JOIN ^^^^^^^^^^^^^^^ You can't access "parts" here - you used table alias, so the only way to access it is using "p.*" > descriptions d ON p.desc_id=d.desc_id; > > NOTICE: Adding missing FROM-clause entry for table "parts" Rewrite your query and show your results. Regards, Tomasz Myrta