| From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
|---|---|
| To: | Leandro Casadei <mateamargo(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Updating with a subselect |
| Date: | 2008-04-23 08:42:16 |
| Message-ID: | 20080423084216.GB16761@svana.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Aarni Ruuhimäki | 2008-04-23 08:49:11 | Re: Postgresql Help |
| Previous Message | Martijn van Oosterhout | 2008-04-23 08:39:54 | Re: plpgsql and logical expression evaluation |