Re: What's the fastest way to do this?

Поиск
Список
Период
Сортировка
Искать
От
Stephan Szabo
Тема
Re: What's the fastest way to do this?
Дата
Msg-id
20011112125042.Y75520-100000@megazone23.bigpanda.com
Ответ на
Список
Дерево обсуждения
Re: What's the fastest way to do this? Orion <o2@trustcommerce.com>
Re: What's the fastest way to do this? Tom Lane <tgl@sss.pgh.pa.us>
Re: What's the fastest way to do this? Stephan Szabo <sszabo@megazone23.bigpanda.com>

On Mon, 12 Nov 2001, Orion wrote:

> UPDATE test
>         SET description = x.description
>         FROM test AS rt, test_tmp AS x
>         WHERE rt.code = x.code;

> So (A) is this a bug or (B) do I totally misunderstand that UPDATE statement
> above.  I appears that it should update each row in table 'test' with the
> description corresponding to the code in test_tmp.  If this is not the
> proper way to do this, what is?

The above update isn't doing what you're expecting.  You're updating
test, you don't need the test as rt in the from unless you are attempting
a self-join.

Try:
update test
 set description = x.description
 from test_tmp as x
 where test.code=x.code;

В списке pgsql-general по дате отправления
От: Manuel Duran Aguete
Дата:
Сообщение: Strange Performance Problem.
От: Tom Lane
Дата:
FAQ