Update from same table

Поиск
Список
Период
Сортировка
От Jürgen Cappel
Тема Update from same table
Дата
Msg-id JEEKIPNAKJNCFLMOBKHGOEDKDCAA.email@juergen-cappel.de
обсуждение исходный текст
Ответы Re: Update from same table  (Josh Berkus <josh@agliodbs.com>)
Список 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 по дате отправления:

Предыдущее
От: daq
Дата:
Сообщение: Re: SQL query
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Update from same table