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