Re: Updating with a subselect - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Updating with a subselect
Date
Msg-id 20080423084216.GB16761@svana.org
Whole thread Raw
In response to Updating with a subselect  ("Leandro Casadei" <mateamargo@gmail.com>)
List pgsql-general
On Tue, Apr 22, 2008 at 01:17:42PM -0300, Leandro Casadei wrote:
> Hi, I need to update a field from a table based in a count.
>
> This is the query:

I don't know why your given query doesn't work, but you could simplify
it which may help.

> update    shops
> set    itemsqty =
>     (
>     select     count(*)
>     from     items i1
>     where  i1.shopid = s0.shopid
>     )
> from     shops s0

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: plpgsql and logical expression evaluation
Next
From: Aarni Ruuhimäki
Date:
Subject: Re: Postgresql Help