X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 05078D1F515 for ; Thu, 14 Aug 2003 14:43:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 41126-06 for ; Thu, 14 Aug 2003 11:42:13 -0300 (ADT) Received: from ems-t.ca (ns.ems-t.ca [209.167.130.34]) by svr1.postgresql.org (Postfix) with ESMTP id 12FBBD1F5A8 for ; Thu, 14 Aug 2003 11:42:28 -0300 (ADT) Received: from ems-t.ca ([141.186.252.65]) by gateway.ems-t.ca with SMTP id <118111>; Thu, 14 Aug 2003 10:55:56 -0400 Received: from MONTREAL-Message_Server by ems-t.ca with Novell_GroupWise; Thu, 14 Aug 2003 10:40:07 -0400 Message-Id: X-Mailer: Novell GroupWise 5.2 Date: Thu, 14 Aug 2003 10:40:02 -0400 From: "Slawek Jarosz" To: pgsql-sql@postgresql.org Subject: Optional join Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/185 X-Sequence-Number: 14801 Hi, I trying to write a query that will join 2 tables. Here's the concept: Table 1: table1, primary key pk1 Table 2: table2, primary key pk2 One of the fields (f2) in table2 contains either the primary key of table1 = or a NULL value. So normally a pretty basic query: SELECT table1.*, table2.pk2 FROM table1, table2 WHERE table2.f2 =3D table1.= pk1;=20=20 BUT what I would like to do is show all records of Table 1 even if there is= no match in Table 2. Meaning that the reults could be=20 table1... table2.pk2 table1... NULL Doable? Thanks.