Re: How to update - Mailing list pgsql-sql

From Manfred Koizar
Subject Re: How to update
Date
Msg-id pfomfug81ska9234r96d3m58gppqimmift@4ax.com
Whole thread Raw
In response to How to update  (Andre Schubert <andre.schubert@km3.de>)
Responses Re: How to update  (Andre Schubert <andre.schubert@km3.de>)
List pgsql-sql
On Mon, 3 Jun 2002 10:00:28 +0200, Andre Schubert
<andre.schubert@km3.de> wrote:
>I tried this, but it update always one row in foo.
>
>update foo set inet=sum(bar.inet),local=sum(bar.local) where foo.ip = bar.ip;

Andre,
this worked in my test:

UPDATE foo  SET inet=b.i, local=b.l FROM (SELECT ip, sum(inet) AS i, sum(local) AS l         FROM bar       GROUP BY
ip)bWHERE foo.ip = b.ip;
 

ServusManfred


pgsql-sql by date:

Previous
From: Andre Schubert
Date:
Subject: How to update
Next
From: Andre Schubert
Date:
Subject: Re: How to update