Re: Correlated subquery/update - Mailing list pgsql-general

From Tom Lane
Subject Re: Correlated subquery/update
Date
Msg-id 15921.979314725@sss.pgh.pa.us
Whole thread Raw
In response to Correlated subquery/update  ("Nick Fankhauser" <nickf@ontko.com>)
List pgsql-general
"Nick Fankhauser" <nickf@ontko.com> writes:
> In essence, I want to match up the records where one.a=two.c and update
> one.b with the value in two.d . In Oracle, I would use this statement:
> update one set b = (select d from two where one.a = two.c);
> in psql, I get a syntax error when I do this.

play=> create table one (a int, b text);
CREATE
play=> create table two (c int, d text);
CREATE
play=> update one set b = (select d from two where one.a = two.c);
UPDATE 0

Looks OK to me (at least in 7.0.* and 7.1).  What release are you using?

            regards, tom lane

pgsql-general by date:

Previous
From: "Nick Fankhauser"
Date:
Subject: Correlated subquery/update
Next
From: Peter Gubis
Date:
Subject: postgres replication