Re: Update two tables returning id from insert CTE Query

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Update two tables returning id from insert CTE Query
Дата
Msg-id CACjxUsN5bS8kMjGZ_nsw-X8=tVuOEHC=HVg3JdSnKwk8pJofUw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Update two tables returning id from insert CTE Query  (Patrick B <patrickbakerbr@gmail.com>)
Ответы Re: Update two tables returning id from insert CTE Query  (Patrick B <patrickbakerbr@gmail.com>)
Список pgsql-general
On Tue, Sep 27, 2016 at 2:59 PM, Patrick B <patrickbakerbr@gmail.com> wrote:

[sel is a relation which can have multiple rows; the fact that it
is being generated in a CTE isn't relevant for purposes of the
error.]

>>>> UPDATE table_2 SET c_id =
>>>> (
>>>>   SELECT c_id
>>>>   FROM sel
>>>>   ORDER BY c_id
>>>> )
>>>> WHERE clientid = 124312;

>>>> ERROR:  more than one row returned by a subquery used as an expression

> isn't clear what I'm trying to achieve?

Nope.

> That's what I need, I just want a way to do that, as the way I'm
> doing isn't working.

You are specifying that you want to assign all the "c_id" values
from the "sel" relation to the "c_id" column in "table2" for any
and all rows which have a "clientid" value of 124312.  Effectively
the database is complaining that it can only store one value, not a
set of values.  I can only guess at what you might be intending to
ask the database to do.  Can you explain what you are trying to do?

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Update two tables returning id from insert CTE Query
Следующее
От: Patrick B
Дата:
Сообщение: Re: Update two tables returning id from insert CTE Query