Skip site navigation (1) Skip section navigation (2)

Re: Select for LEFT JOIN

From: tolik(at)aaanet(dot)ru (Anatoly K(dot) Lasareff)
To: Linh Luong <linh(dot)luong(at)computalog(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Select for LEFT JOIN
Date: 2001-05-29 06:29:07
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
>>>>> "LL" == Linh Luong <linh(dot)luong(at)computalog(dot)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:


In addition you can use aliases for field names:

select as abc1, as abc2, ....

Anatoly K. Lasareff                 Email:    tolik(at)aaanet(dot)ru 

In response to

pgsql-sql by date

Next:From: Tom LaneDate: 2001-05-29 13:46:03
Subject: Re: Re: [SQL] Difficult SQL Statement
Previous:From: Tim BarnardDate: 2001-05-28 22:36:22
Subject: Re: [SQL] Difficult SQL Statement

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group