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

Re: RE: [SQL] Why *no* ambig.uous complain in select part?

From: Mark Roberts <mailing_lists(at)pandapocket(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: Luigi Castro Cardeles <luigi(dot)cardeles(at)gmail(dot)com>, PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: RE: [SQL] Why *no* ambig.uous complain in select part?
Date: 2008-08-22 21:33:59
Message-ID: 1219440839.6163.211.camel@localhost (view raw or flat)
Thread:
Lists: pgsql-sql
On Fri, 2008-08-22 at 17:10 -0400, Emi Lu wrote:
> 
> Would you please give me an example?
> 
> I have two tables like the following:
> T1 (col1 varchar, col2 varchar, primary key (col1, col2))
> T2 (col1 varchar, col2 varchar, primary key (col1, col2))
> 
> 
> Query I have is:
> ===================
> select col1, col2
> from      T1
> left join T2 using (T1, T2);
> 
> Thanks a lot!

If (T1.col1, T1.col2) != (T2.col1, T2.col2) then the join is
unsuccessful and T2.col1 and T2.col2 will be null.  If you're wondreing
if the join was successful:

select col1, col2
from T1
    left outer join T2 using (col1, col2)
where T2.col1 is not null

-Mark


In response to

pgsql-sql by date

Next:From: Tom LaneDate: 2008-08-22 22:41:30
Subject: Re: Why *no* ambig·uous complain in select part?
Previous:From: Emi LuDate: 2008-08-22 21:10:33
Subject: Re: RE: [SQL] Why *no* ambig.uous complain in select part?

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