Re: Problem with joins
От | Thomas Lockhart |
---|---|
Тема | Re: Problem with joins |
Дата | |
Msg-id | 39634780.17592BFF@alumni.caltech.edu обсуждение исходный текст |
Ответ на | Problem with joins ("Jean-Marc Libs" <jean-marc.libs@obs.coe.int>) |
Список | pgsql-sql |
> 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 fromsource where source_id not in (select data_source_id from data); - Thomas
В списке pgsql-sql по дате отправления: