Received: from merganser.its.uu.se (merganser.its.uu.se [130.238.6.236]) by hub.org (8.9.3/8.9.3) with ESMTP id JAA11024 for ; Sun, 5 Mar 2000 09:13:19 -0500 (EST) (envelope-from peter@localhost.its.uu.se) Received: from regulus.its.uu.se ([130.238.7.19]:64733 "EHLO regulus.its.uu.se") by merganser.its.uu.se with ESMTP id ; Sun, 5 Mar 2000 15:12:23 +0100 Received: from peter (helo=localhost) by regulus.its.uu.se with local-esmtp (Exim 3.02 #2) id 12Rbol-0000AQ-00; Sun, 05 Mar 2000 15:15:35 +0100 Date: Sun, 5 Mar 2000 15:15:35 +0100 (CET) From: Peter Eisentraut To: Nikolaj Lundsgaard cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Left Join In-Reply-To: <004701bf868f$aeca44c0$bcd426c0@kampsax.dtu.dk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: Peter Eisentraut Nikolaj Lundsgaard writes: > How do make a left join in postgresql ? Outer joins aren't supported yet. You can generally do something like select a2, b2 from a, b where a1 = b1 union select a2, NULL from a where a1 not in (select b1 from b); which is not very extensible to more than two tables. Alternatively you can make a function that returns the corresponding value from b2 given an a2 value, or some default if there isn't any corresponding one. Look into the archives for outer joins for countless specifics on this. -- Peter Eisentraut Sernanders väg 10:115 peter_e@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden