Update from same table - Mailing list pgsql-sql

From Jürgen Cappel
Subject Update from same table
Date
Msg-id JEEKIPNAKJNCFLMOBKHGOEDKDCAA.email@juergen-cappel.de
Whole thread Raw
Responses Re: Update from same table
List pgsql-sql
Hello,

I want to update columns in a table that match a fixed key
from the same column of the same table matching another fixed key.
There can be several tuples per key distinguished by a secondary id.
Tuples are unique with the combined keys. Maybe a query could look
something like this:
UPDATE a.mytable from b.mytableSET a.mycolumn = b.mycolumnWHERE a.firstid = some_keyAND b.firstid = some_other_keyAND
a.secondaryid= b.secondaryid;
 

But it's a syntax error. I tried a subselect but i'm failing to connect
the subselect's 2nd ID with the update's 2nd ID.  Any help ?  Thanks,

Jürgen



pgsql-sql by date:

Previous
From: daq
Date:
Subject: Re: SQL query
Next
From: Josh Berkus
Date:
Subject: Re: Update from same table