From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Frank Joerdens <frank@joerdens.de>
Cc: pgsql-sql@postgresql.org
Cc: hank@fas-art.com
Cc: annette@fas-art.com
Subject: Re: Looking for the correct solution for a generic problem.
Date: Thu, 7 Feb 2002 13:31:03 -0800 (PST)
Message-ID: <20020207132603.D32753-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <20020207215234.A6766@superfly.archi-me-des.de>
On Thu, 7 Feb 2002, Frank Joerdens wrote:
> Now I want to retrieve rows from A as in
>
> SELECT DISTINCT A.foo
> FROM A,B
> WHERE A.foo [matches some criteria]
> OR B.bar [matches some other criteria]
> AND A.id = B.a_id;
>
> 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. If the column bar in B matches the desired criteria, I also
> want the rows in A that are linked to those rows in B.
Sounds like you want a left outer join.
Maybe...
select distinct a.foo from
a left outer join b on (a.ID = b.a_id)
where a.foo [matches] or B.bar [matches]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, frank@joerdens.de, hank@fas-art.com, annette@fas-art.com
Subject: Re: Looking for the correct solution for a generic problem.
In-Reply-To: <20020207132603.D32753-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox