Re: 3 tables join update

From: Alban Hertroys <a(dot)hertroys(at)magproductions(dot)nl>
To: rihad <rihad(at)mail(dot)ru>
Cc: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: 3 tables join update
Date: 2007-10-01 08:53:25
Message-ID: 4700B585.7040503@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

rihad wrote:
> Richard Broersma Jr wrote:
> UPDATE Foo foo
> SET ...
> FROM LEFT JOIN Bar bar USING(common_field)
> WHERE blah='blah' AND bar.common_field IS NULL;
>
> ERROR: syntax error at or near "JOIN"
>
>
> I know I'm misusing UPDATE ... FROM because I don't really want Bar's
> values to go into Foo, but only using them for a conditional update
> (atomically I hope).

Oh, you mean:

UPDATE foo
SET ...
WHERE blah = 'blah'
AND NOT EXISTS (
SELECT 1 FROM baz WHERE foo.common_field = baz.common_field
)

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Goboxe 2007-10-01 09:17:47 Partitioned table limitation
Previous Message Alban Hertroys 2007-10-01 08:37:31 Re: more problems with count(*) on large table