From: | Manfred Koizar <mkoi-pg(at)aon(dot)at> |
---|---|
To: | "João" Paulo Batistella <batistellabr(at)yahoo(dot)com(dot)br> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Select in update |
Date: | 2002-07-09 09:52:08 |
Message-ID: | 03cliuckc34vmg3q44skgip07a3dnclbnl@4ax.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, 8 Jul 2002 12:35:23 -0700 (PDT), "João" Paulo Batistella
<batistellabr(at)yahoo(dot)com(dot)br> wrote:
>I need to update a table (13000 rows) using something
>like this:
>update rua set cod_bairro =
>(select cod_bairro from bairro b where b.vetbairro =
>r.vetbairro)
JP, you were close to it. Your statement would work if you change it
to
update rua
set cod_bairro = (select cod_bairro
from bairro b
where b.vetbairro = rua.vetbairro)
^^^
and if vetbairro is unique in bairro (at least for the values of
vetbairro appearing in rua). And if it works, then the following
statement should also work, probably faster:
UPDATE rua
SET cod_bairro = b.cod_bairro
FROM bairro b
WHERE b.vetbairro = rua.vetbairro;
Servus
Manfred
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2002-07-09 10:52:29 | Re: Query Casting Help |
Previous Message | Manfred Koizar | 2002-07-09 09:40:34 | Re: Speeding up subselect ? |