Re: Syntax question - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Syntax question
Date
Msg-id 20060526163542.GA13481@wolff.to
Whole thread Raw
In response to Syntax question  (John Taylor <d_low22003@yahoo.com>)
List pgsql-general
On Fri, May 26, 2006 at 09:09:25 -0700,
  John Taylor <d_low22003@yahoo.com> 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.prodidand pa.prodid. IOW, if there's a match between prod.prodid and pa.prodid, I want the output from both the
producttable and the prod_alias table.  if there's no match, I still want the output from product table. Can I do this
inone 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.

pgsql-general by date:

Previous
From: Jorge Godoy
Date:
Subject: Re: LDAP authentication
Next
From: "A. Kretschmer"
Date:
Subject: Re: Syntax question