Re: How to update

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: Andre Schubert <andre(dot)schubert(at)km3(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to update
Date: 2002-06-03 13:08:46
Message-ID: pfomfug81ska9234r96d3m58gppqimmift@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 3 Jun 2002 10:00:28 +0200, Andre Schubert
<andre(dot)schubert(at)km3(dot)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) b
WHERE foo.ip = b.ip;

Servus
Manfred

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andre Schubert 2002-06-03 13:46:46 Re: How to update
Previous Message Andre Schubert 2002-06-03 08:00:28 How to update