Re: How to update

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

On Mon, 03 Jun 2002 15:08:46 +0200
"Manfred Koizar" <mkoi-pg(at)aon(dot)at> wrote:

> 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

Thank you very much, this always works for me... :)

Regards

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kaare Rasmussen 2002-06-03 16:04:56 Re: to_date()
Previous Message Manfred Koizar 2002-06-03 13:08:46 Re: How to update