Re: Correlated subquery/update

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nick Fankhauser" <nickf(at)ontko(dot)com>
Cc: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Correlated subquery/update
Date: 2001-01-12 15:52:05
Message-ID: 15921.979314725@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Nick Fankhauser" <nickf(at)ontko(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Gubis 2001-01-12 15:56:27 postgres replication
Previous Message Nick Fankhauser 2001-01-12 15:42:31 Correlated subquery/update