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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-sql by date

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