Re: Select for LEFT JOIN

Поиск
Список
Период
Сортировка
От tolik@aaanet.ru (Anatoly K. Lasareff)
Тема Re: Select for LEFT JOIN
Дата
Msg-id 861yp8mzws.fsf@tolikus.hq.aaanet.ru
обсуждение исходный текст
Ответ на Select for LEFT JOIN  (Linh Luong <linh.luong@computalog.com>)
Список pgsql-sql
>>>>> "LL" == Linh Luong <linh.luong@computalog.com> writes:
LL> Hi,LL> I am trying to do a 2 joins between 3 tables.
LL> ie) LL> select <some field>, coalesce(TRR.ABC, SOC.ABC) as newABC, ...LL> from A join (B join C on (..)) on (..))
asTRR LL> left join LL> (D join E on (..)) as SOC on (TRR.Field1=SOC.Field2)
 
LL> When I run this it says that there is an ambiguous field.  Yes after theLL> join for TRR and SOC they both contain
afields name ABC.  How can ILL> rename this field in the sql statement or how can I make it so the sqlLL> statement
knowthat they are different.
 
LL> Please help.. .thanks

You have to use full-qualifyed field names, like this:

select trr.abc, soc.abc,....

In addition you can use aliases for field names:

select trr.abc as abc1, soc.abc as abc2, ....

-- 
Anatoly K. Lasareff                 Email:    tolik@aaanet.ru
http://tolikus.hq.aaanet.ru:8080


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

Предыдущее
От: Najm Hashmi
Дата:
Сообщение: ERROR: parser: parse error at or near "$1"
Следующее
От: george young
Дата:
Сообщение: Re: sql user management