Left joins with multiple tables

Поиск
Список
Период
Сортировка
От Colin Fox
Тема Left joins with multiple tables
Дата
Msg-id pan.2004.01.17.02.29.56.311442@cfconsulting.ca
обсуждение исходный текст
Ответы Re: Left joins with multiple tables
Список pgsql-sql
Hi, all.

I've got a bit of a problem here. I have 4 tables - people, a, b, c (not
the original names).

For each person in the people table, they may or may not have a record in
a, may or may not have a record in b, and may or may not have a record in
c.

Handling the first table (a) is easy:

select id, name
from people p left outer join a on a.person_id = p id;

But I'd like to be able to do something like:

select   id, name, a.field1, b.field2, c.field3
from   people p left outer join a on a.person_id = p id,   people p left outer join b on b.person_id = p.id,   people p
leftouter join c on c.person_id = p.id;
 

Naturally you can't repeat the 'people p' clause 3 times, but is there
some other syntax that would let me do this?

Thanks! cf




В списке pgsql-sql по дате отправления:

Предыдущее
От: "Thomas Wegner"
Дата:
Сообщение: Problem with LEFT JOIN
Следующее
От: nkunkov@optonline.net (Liza)
Дата:
Сообщение: simple tree in postgress