Re: Update FROM clause?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Update FROM clause?
Дата
Msg-id 1197.1036181939@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Update FROM clause?  ("Booth, Robert" <Robert_Booth@intuit.com>)
Список pgsql-general
"Booth, Robert" <Robert_Booth@intuit.com> writes:
> SELECT count(*)
>   FROM (allforms LEFT OUTER JOIN aanda ON allforms.file__no =
> aanda.file__no)
>  INNER JOIN formsin ON allforms.file__no = formsin.file__no
>  WHERE ... Omitted ...

> The Postgres UPDATE Query:
> UPDATE allforms
>    SET status = 'Okay to Edit'
>   FROM formsin LEFT OUTER JOIN aanda ON formsin.file__no = aanda.file__no
>  WHERE allforms.file__no = formsin.file__no
>    AND ... Omitted, matches the Access Query ...

Those are not the same thing at all.  Your UPDATE is more like

SELECT ...
FROM allforms,
     (formsin LEFT OUTER JOIN aanda ON formsin.file__no = aanda.file__no)
WHERE allforms.file__no = formsin.file__no
  AND ... Omitted, matches the Access Query ...

which is reversing the order of the inner and outer join steps.
Depending on your data this might yield quite a different result.

            regards, tom lane

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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: [Q] Sequences, last_value and inserts
Следующее
От: "Roderick A. Anderson"
Дата:
Сообщение: Re: [Q] Sequences, last_value and inserts