Re: Putting an aggregate value in an UPDATE statement...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Putting an aggregate value in an UPDATE statement...
Дата
Msg-id 9432.1275426952@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Putting an aggregate value in an UPDATE statement...  (John Gage <jsmgage@numericable.fr>)
Ответы Re: Putting an aggregate value in an UPDATE statement...  (Leif Biberg Kristensen <leif@solumslekt.org>)
Список pgsql-novice
John Gage <jsmgage@numericable.fr> writes:
> Thanks.  I tried that _without_ the parentheses around the select
> statement and it didn't work.

> At the risk of further displaying ignorance, why are the parens
> necessary, what do they do?

You need them to syntactically separate the sub-select from the outer
select.  If SQL didn't require them, then in something like

    UPDATE question_choices SET total_rows =
        select count(*) from care_lesson where something

it wouldn't be clear whether the WHERE clause was meant to attach
to the sub-select or the outer UPDATE.

            regards, tom lane

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

Предыдущее
От: Leif Biberg Kristensen
Дата:
Сообщение: Re: Putting an aggregate value in an UPDATE statement...
Следующее
От: Leif Biberg Kristensen
Дата:
Сообщение: Re: Putting an aggregate value in an UPDATE statement...