Column name

Started by Linh Luongalmost 25 years ago2 messagesgeneral
Jump to latest
#1Linh Luong
linh.luong@computalog.com

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

#2Gyozo Papp
pgerzson@freestart.hu
In reply to: Linh Luong (#1)
Re: Column name

after the table alias you can rename your cloumns in join:

select <some field>, coalesce(TRR.ABC, SOC.ABC) as newABC, ...
from A join (B join C on (..)) on (..))

as TRR(<new column names>) <-- here

left join
(D join E on (..)) as SOC on (TRR.Field1=SOC.Field2)

----- Original Message -----
From: "Linh Luong" <linh.luong@computalog.com>
To: <pgsql-general@postgresql.org>
Sent: 2001. m�jus 24. 21:58
Subject: [GENERAL] Column name

Show quoted text

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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster