Re: update ... set ... subquery

From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: update ... set ... subquery
Date: 2010-03-17 19:52:06
Message-ID: e4edc9361003171252p2aa3d481y5831f1cf454cc566@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/3/17 John Smith <jayzee(dot)smith(at)gmail(dot)com>

> guys,
> trying multiple updates without success like so:
>
> update a
> set number = any ( select number from b where
> a.number=b.number)
> where number is null;
> >> 'syntax error at or near "any"'
>
> subquery returns more than one row. using 8.1.
> thks, jzs
>
>
If the subquery returns multiple values, which value do you want to set to
the 'number' column. For each record there can be only one value for this
column?
The subquery has to return only one value such a query.

Show the tables structure, maybe there is a better column than the 'number'
to join the 'a' and 'b' tables.

regards
Szymon Guz

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Carsten Kropf 2010-03-17 19:56:05 Re: building a c function
Previous Message Tom Lane 2010-03-17 19:34:42 Re: building a c function