Received: from gyw.com (gyw.com [209.55.67.177]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f34FFn841053 for ; Wed, 4 Apr 2001 11:15:49 -0400 (EDT) (envelope-from tjk@tksoft.com) Received: from smtp3.tksoft.com (smtp3.tksoft.com [192.168.50.56] (may be forged)) by gyw.com (8.8.8/8.8.8) with ESMTP id IAA17888; Wed, 4 Apr 2001 08:37:00 -0700 Received: (from tjk@tksoft.com) by smtp3.tksoft.com (8.8.8/8.8.8) id HAA10925; Wed, 4 Apr 2001 07:22:44 -0700 From: "tjk@tksoft.com" Message-Id: <200104041422.HAA10925@smtp3.tksoft.com> Subject: Re: outer joins To: asakmanas@grafton.lt (=?iso-8859-4?Q?Algirdas_=A9akmanas?=) Date: Wed, 4 Apr 2001 07:22:43 -0700 (PDT) Cc: pgsql-sql@postgresql.org In-Reply-To: from "=?iso-8859-4?Q?Algirdas_=A9akmanas?=" at Apr 04, 2001 01:03:11 PM X-Info: None MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200104/45 X-Sequence-Number: 2384 Algirdas, This should do the trick: SELECT a.id,b.name FROM a,b WHERE a.id=b.id UNION SELECT id,null FROM a WHERE id NOT IN (SELECT id FROM b); Troy > > Hi all, > > I'm new to postgre, I've changed my work and consequently now i'm moving > from MS plaform. > In MS SQL there are such constructs left or right outer join, in postgres > there are no such thing > > Can You offer me strategy to make query that selects from table (a) and > joins to it another (b) > on e.g. a.id=b.aid but joins so that in case there is no value in table b > NULL is left in result: > in MS SQL i've used query: > > select a.id, b.name from a left outer join b on a.id=b.aid > > table a table b > > id | aid | name > ----------- ---------------- > 1 1 | Tom > 2 3 | Sam > > result: > a.id | b.name > --------------------- > 1 | Tom > 2 | NULL > > thank you in advance > > Algirdas Šakmanas > IT manager > +370 99 90369 > asakmanas@grafton.lt > Grafton Entertainment > http://www.tvnet.lt > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >