Re: Bug or syntax error in my update query with a FROM statement ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Bug or syntax error in my update query with a FROM statement ?
Дата
Msg-id 12058.1019659322@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Bug or syntax error in my update query with a FROM statement ?  ("ARP" <arnaud.mlist1@free.fr>)
Список pgsql-general
"ARP" <arnaud.mlist1@free.fr> writes:
> I would tend to agree with you but why doesn't it update ANY row when
> count() equals zero then, and ALL rows only when the count is not zero?

Because you've written a three-way join.  The target table is
unconstrained --- but if there are no pairs of rows of the other two
tables that satisfy the WHERE clause, there will be no three-way
combinations that do either, and so there are no rows selected to be
updated.  On the other hand, if any pair of rows of the other two
table satisfy WHERE, *all* rows of the target table will be joined
to them to make updatable rows.

It's useful to think of the behavior of UPDATE as exactly like a
SELECT, except that rather than reporting the selected rows to you,
it changes them per the SET target list.  Had you written

select utilisateur.* from utilisateur, utilisateur a, ancien b
where a.util_id=b.util_id and b.anc_deces is not null and
      (a.login<>'*' or a.password<>'*');

the error would be moderately obvious, no?

            regards, tom lane

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: problems with non-trust authentication methods in 7.3devel?
Следующее
От: David Link
Дата:
Сообщение: Re: Why is outer Join way quicker?