Received: from huey.jpl.nasa.gov (huey.jpl.nasa.gov [128.149.68.100]) by hub.org (8.10.1/8.10.1) with ESMTP id e65EVSS65648 for ; Wed, 5 Jul 2000 10:31:28 -0400 (EDT) Received: from golem.jpl.nasa.gov (hectic-1 [128.149.68.203]) by huey.jpl.nasa.gov (8.8.8+Sun/8.8.8) with ESMTP id HAA04193; Wed, 5 Jul 2000 07:31:19 -0700 (PDT) Received: from alumni.caltech.edu (localhost.localdomain [127.0.0.1]) by golem.jpl.nasa.gov (Postfix) with ESMTP id 47E116F4F; Wed, 5 Jul 2000 14:34:40 +0000 (UTC) Message-ID: <39634780.17592BFF@alumni.caltech.edu> Date: Wed, 05 Jul 2000 14:34:40 +0000 From: Thomas Lockhart Organization: Yes X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.14-15mdksmp i686) X-Accept-Language: en MIME-Version: 1.0 To: jml@obs.coe.int Cc: pgsql-sql@postgresql.org Subject: Re: Problem with joins References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200007/45 > I want to get a list of data sources with the corresponding data, > if the data exists, or with null, if the data doesn't. But anyway > I need the data sources (all of them). You want an outer join. Postgres doesn't have that yet, but you can mimic it. > 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. Close. Try select source_name,data_value from source,data where data_source_id=source_id union select source_name,source_id,NULL from source where source_id not in (select data_source_id from data); - Thomas