Re: How to use outer join in update

From: Harald Fuchs <hf1110x(at)protecting(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to use outer join in update
Date: 2006-12-08 12:42:33
Message-ID: puu006d0ee.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <45792BC1(dot)3040305(at)magproductions(dot)nl>,
Alban Hertroys <alban(at)magproductions(dot)nl> writes:

> Andrus wrote:
>> In my current DBMS I can use
>>
>> create table t1 ( f1 int, f2 int );
>> create table t2 ( f3 int, f4 int );
>> update t1 set f1=t2.f3 from t1 left join t2 on t1.f2=t2.f4

> That looks like a self-join on t1 without using an alias for the second
> instance of t1.

> I think you meant:
> update t1 set f1=t2.f3 from t2 where f2 = t2.f4

Or this one:

UPDATE t1
SET f1 = t2.f3
FROM t1 x
LEFT JOIN t2 ON x.f2 = t2.f4
WHERE x.f2 = t1.f2

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2006-12-08 12:50:34 Re: Excluding schema from backup
Previous Message BigSmoke 2006-12-08 12:35:56 Re: The relative stability of different procedural languages