X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6780F9FA12E for ; Fri, 26 May 2006 13:33:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 66503-10 for ; Fri, 26 May 2006 13:33:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wolff.to (wolff.to [66.93.197.194]) by postgresql.org (Postfix) with SMTP id F40329FA2DB for ; Fri, 26 May 2006 13:33:34 -0300 (ADT) Received: (qmail 14398 invoked by uid 500); 26 May 2006 16:35:42 -0000 Date: Fri, 26 May 2006 11:35:42 -0500 From: Bruno Wolff III To: John Taylor Cc: pgsql-general@postgresql.org Subject: Re: Syntax question Message-ID: <20060526163542.GA13481@wolff.to> Mail-Followup-To: Bruno Wolff III , John Taylor , pgsql-general@postgresql.org References: <20060526160925.61343.qmail@web53504.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060526160925.61343.qmail@web53504.mail.yahoo.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/1318 X-Sequence-Number: 96110 On Fri, May 26, 2006 at 09:09:25 -0700, John Taylor wrote: > I have a select statement that goes as follows: > > SELECT * FROM product prod, prod_alias pa, category cat, company co > WHERE prod.catid = cat.catid > AND prod.coid = co.coid > AND prod.prodid = pa.prodid; > > If possible, I want to change the statement so that I get output regardless of whether there's a match between prod.prodid and pa.prodid. IOW, if there's a match between prod.prodid and pa.prodid, I want the output from both the product table and the prod_alias table. if there's no match, I still want the output from product table. Can I do this in one select statement? This is what outer joins are used for. See http://developer.postgresql.org/docs/postgres/sql-select.html for the syntax and a very brief description of what they do.