Re: UPDATE query based on a SELECT command.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: UPDATE query based on a SELECT command.
Дата
Msg-id 26560.1327777964@sss.pgh.pa.us
обсуждение исходный текст
Ответ на UPDATE query based on a SELECT command.  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Список pgsql-novice
JORGE MALDONADO <jorgemal1960@gmail.com> writes:
> Let's suppose that I have an UPDATE query which includes a SELECT as part
> of it as follows:

> UPDATE table1
> SET field1 = (SELECT fieldx FROM table2 WHERE .........)

> What happens if the result of the SELECT command does not return any row?

A scalar subquery that returns no rows has a result of NULL.  This is
not specific to whether it's used in UPDATE.  See
http://www.postgresql.org/docs/9.1/static/sql-expressions.html#SQL-SYNTAX-SCALAR-SUBQUERIES

            regards, tom lane

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

Предыдущее
От: JORGE MALDONADO
Дата:
Сообщение: UPDATE query based on a SELECT command.
Следующее
От: "Craig Boyd"
Дата:
Сообщение: Re: PostgreSQL v8 & v9 on the same XP machine - SOLVED