Re: Mass Update

From: Niederland <niederland(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Mass Update
Date: 2007-04-23 13:51:14
Message-ID: 1177336274.654572.127920@b58g2000hsg.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Apr 23, 4:25 am, Iain Adams <aca04(dot)(dot)(dot)(at)shef(dot)ac(dot)uk> wrote:
> Hi,
>
> This is probably a really easy question but I have been toiling with
> this SQL for ages.
> Okay I have a table with geom_id and id in, this table is called temp.
> I also have another table called junctions with a column, old_id. Now
> old_id corresponds to geom_id. I want to update the junctions table
> column id with the id held in temp where the geom_id column matches
> the old_id column.
>
> I would really appreciate some help on this. I just cant seem to get
> it right.
>
> Thanks
>
> Iain

update junctions set id = (select id from temp where temp.geom_id =
junctions.old_id AND temp.id <> junctions.id);

This assumes that their is no more then 1 cooresponding geom_id for
each old_id.

Roger

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Felix Kater 2007-04-23 14:07:54 PQerrorMessage: suppress trailing new line?
Previous Message chrisj 2007-04-23 12:56:26 Re: selective export for subsequent import (COPY)