Re: What's the fastest way to do this? - Mailing list pgsql-general

From Stephan Szabo
Subject Re: What's the fastest way to do this?
Date
Msg-id 20011112125042.Y75520-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: What's the fastest way to do this?  (Orion <o2@trustcommerce.com>)
List pgsql-general
On Mon, 12 Nov 2001, Orion wrote:

> UPDATE test
>         SET description = x.description
>         FROM test AS rt, test_tmp AS x
>         WHERE rt.code = x.code;

> So (A) is this a bug or (B) do I totally misunderstand that UPDATE statement
> above.  I appears that it should update each row in table 'test' with the
> description corresponding to the code in test_tmp.  If this is not the
> proper way to do this, what is?

The above update isn't doing what you're expecting.  You're updating
test, you don't need the test as rt in the from unless you are attempting
a self-join.

Try:
update test
 set description = x.description
 from test_tmp as x
 where test.code=x.code;


pgsql-general by date:

Previous
From: Manuel Duran Aguete
Date:
Subject: Strange Performance Problem.
Next
From: Tom Lane
Date:
Subject: Re: What's the fastest way to do this?