pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSelect for LEFT JOIN
2+ messages / 2 participants
[nested] [flat]
* Select for LEFT JOIN
@ 2001-05-24 21:04 Linh Luong <linh.luong@computalog.com>
0 siblings, 1 reply; 2+ messages in thread
From: Linh Luong @ 2001-05-24 21:04 UTC (permalink / raw)
To: pgsql-sql
Hi,
I am trying to do a 2 joins between 3 tables.
ie)
select <some field>, coalesce(TRR.ABC, SOC.ABC) as newABC, ...
from A join (B join C on (..)) on (..)) as TRR
left join
(D join E on (..)) as SOC on (TRR.Field1=SOC.Field2)
When I run this it says that there is an ambiguous field. Yes after the
join for TRR and SOC they both contain a fields name ABC. How can I
rename this field in the sql statement or how can I make it so the sql
statement know that they are different.
Please help.. .thanks
--
Linh Luong
Computalog Ltd.
Software Developer
Phone: (780) 464-6686 (ext 325)
Email: linh.luong@computalog.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Select for LEFT JOIN
@ 2001-05-29 06:29 Anatoly K. Lasareff <tolik@aaanet.ru>
parent: Linh Luong <linh.luong@computalog.com>
0 siblings, 0 replies; 2+ messages in thread
From: tolik@aaanet.ru @ 2001-05-29 06:29 UTC (permalink / raw)
To: Linh Luong <linh.luong@computalog.com>; +Cc: 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 (..)) as TRR
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 the
LL> join for TRR and SOC they both contain a fields name ABC. How can I
LL> rename this field in the sql statement or how can I make it so the sql
LL> statement know that 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-05-29 06:29 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-24 21:04 Select for LEFT JOIN Linh Luong <linh.luong@computalog.com>
2001-05-29 06:29 ` Anatoly K. Lasareff <tolik@aaanet.ru>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox