Re: update a table from a temp table

Поиск
Список
Период
Сортировка
От Thom Brown
Тема Re: update a table from a temp table
Дата
Msg-id AANLkTin=Hoxow4Ebd5h1ieTv4=reSUcMz9A-JUCroxwE@mail.gmail.com
обсуждение исходный текст
Ответ на update a table from a temp table  (Charles Holleran <scorpdaddy@hotmail.com>)
Список pgsql-novice
On 17 August 2010 19:09, Charles Holleran <scorpdaddy@hotmail.com> wrote:
> Referring to the syntax for updating a table from a temp table at "Update a
> field in a table using a value from another table ..." at
> http://www.cryer.co.uk/brian/sql/sql_crib_sheet.htm
>
> Is this the correct syntax for PG for updating a table from a temp table?
>

No, you need to use a FROM clause if you wish to update based on another table.

Taking the example from that page you linked to:

UPDATE tableone
SET field1 = tabletwo.fieldx
FROM tabletwo
WHERE tableone.commonid = tabletwo.commonid;

Look at http://www.postgresql.org/docs/current/static/sql-update.html
for more information.

Regards
--
Thom Brown
Registered Linux user: #516935

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

Предыдущее
От: Charles Holleran
Дата:
Сообщение: update a table from a temp table
Следующее
От: "Charles Holleran "
Дата:
Сообщение: Re: update a table from a temp table