Re: Table UPDATE statement

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Table UPDATE statement
Дата
Msg-id 421F0C88.7000402@magproductions.nl
обсуждение исходный текст
Ответ на Table UPDATE statement  (Venkatesh Babu <venkatbabukr@yahoo.com>)
Ответы Re: Table UPDATE statement  (Venkatesh Babu <venkatbabukr@yahoo.com>)
Список pgsql-general
Venkatesh Babu wrote:
> Hello,
>
> I need to update few rows of a table (call it 't') and
> need to set just one column col1 (out of around 100
> columns... to be exact, our table has 116 columns).
> The info about rows to be updated is present in
> another table t2. t2 just contains 2 columns (row_key,
> new value for col1).
>
> What is the best way to perform update? Can't I give
> an update statement like: UPDATE t set
> col1=t2.new_col1_val where t1.row_key = t2.row_key
> ???? I think this kind of support is provided in db2,
> but couldn't find how this can be done in postgres.

You're close:

UPDATE t1
    SET col1 = t2.new_col1
   FROM t2
  WHERE t1.row_key = t2.row_key;

--
Alban Hertroys
MAG Productions

T: +31(0)53 4346874
F: +31(0)53 4346876
E: alban@magproductions.nl
W: http://www.magproductions.nl

В списке pgsql-general по дате отправления:

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: basic trigger using OLD not working?
Следующее
От: "Jatinder Sangha"
Дата:
Сообщение: Re: Unicode support problem