From: Mark Nielsen <python@kepnet.net>
To: pgsql-sql@postgresql.org
Subject: Re: Looking for the correct solution for a generic problem.
Date: Thu, 07 Feb 2002 15:53:02 -0500
Message-ID: <3C62E92E.3020405@kepnet.net> (raw)
References: <20020207215234.A6766@superfly.archi-me-des.de>
Frank Joerdens wrote:
> I've been wondering about this for quite a while now. And I suspect
> there is a bog-standard way that is better than the rather clumsy
> approach I am following now (it feels clumsy anyway). I've got table B
> which is linked to table A as in
>
> CREATE TABLE A (
> id serial,
> foo text,
> );
>
> CREATE TABLE B (
> a_id int references A (id),
> id serial,
> bar text
> );
>
> 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;
>
Perhaps I am clueless, but wouldn't you want to do this
SELECT DISTINCT A.foo
FROM A,B
WHERE ((A.foo =1)
OR (B.bar =2))
AND A.id = B.a_id;
Actually, I think the outerjoin is right.
I had problems like this in the past. I think the other posts answer it.
Mark
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: python@kepnet.net
Subject: Re: Looking for the correct solution for a generic problem.
In-Reply-To: <3C62E92E.3020405@kepnet.net>
* 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