Re: Looking for the correct solution for a generic problem.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Frank Joerdens <frank(at)joerdens(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org, hank(at)fas-art(dot)com, annette(at)fas-art(dot)com
Subject: Re: Looking for the correct solution for a generic problem.
Date: 2002-02-07 21:50:53
Message-ID: 18832.1013118653@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Frank Joerdens <frank(at)joerdens(dot)de> writes:
> This works fine if there is *at least* one row in B for each row in A.
> If there isn't, I obviously get 0 results even if the column foo in A
> matches the desired criteria. But I do want the rows from A even if
> there is no row in B that is linked to those rows in A that match the
> criteria.

You want an "outer join". Something like
FROM A LEFT JOIN B ON (A.id = B.a_id)
WHERE [other criteria]

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Joerdens 2002-02-07 22:04:48 Re: Looking for the correct solution for a generic problem.
Previous Message Stephan Szabo 2002-02-07 21:31:03 Re: Looking for the correct solution for a generic problem.