double left outer join on the same table

Поиск
Список
Период
Сортировка
От T E Schmitz
Тема double left outer join on the same table
Дата
Msg-id 4095207C.8080009@numerixtechnology.de
обсуждение исходный текст
Ответы Re: double left outer join on the same table  (Adam Witney <awitney@sghms.ac.uk>)
Список pgsql-sql
Hello,

I have two tables SECTION and BRAND. SECTION is related to BRAND via two 
foreign keys. I would like to select ALL SECTIONs whether the FKs are 
null or not and fetch the BRAND attributes in one SQL statement. In 
other words I need a double outer join.

Is this possible at all?

The following doesn't work for two reasons:
a) Table name "brand" specified more than once.
b) how would I specify the same output columns twice?

SELECT
SECTION.SECTION_PK,
SECTION.SECTION_NAME,
SECTION.BRAND_1_FK,
SECTION.BRAND_2_FK,
BRAND.BRAND_PK,
BRAND.BRAND_NAME

FROM SECTION
left outer join BRAND  on BRAND_PK =BRAND_1_FK
left outer join BRAND  on BRAND_PK =BRAND_2_FK


-- 


Regards,

Tarlika Elisabeth Schmitz


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Permissions not working
Следующее
От: Adam Witney
Дата:
Сообщение: Re: double left outer join on the same table