From: Gerhard Dieringer <DieringG@eba-haus.de>
To: jean-marc.libs@obs.coe.int
Cc: pgsql-sql@postgresql.org
Subject: Antw: Problem with joins
Date: Wed, 05 Jul 2000 12:31:16 +0200
Message-ID: <s9632aa2.096@kopo001> (raw)
Jean-Marc Libs wrote:
>...
>I have also tried:
>select source_name,data_value from source,data where data_source_id=source_id union select source_name,source_id,NULL from source,data
>This is a bit better, in the sense that I get back all I need, but there
>are too many lines: when there is data, I get the line with the data value
>and also with NULL.
>...
You are on the right way. Change your querry to
select source_name,data_value
from source,data
where data_source_id=source_id
union
select source_name,source_id
from source
WHERE source_id NOT IN (SELECT source_id FROM data);
and you will get your expected result.
BTW this simulates an outer join.
Gerhard
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: DieringG@eba-haus.de, jean-marc.libs@obs.coe.int
Subject: Re: Problem with joins
In-Reply-To: <s9632aa2.096@kopo001>
References: <s9632aa2.096@kopo001>
* 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