From: Andre Schubert <andre.schubert@km3.de>
To: pgsql-sql@postgresql.org
Subject: How to update
Date: Mon, 3 Jun 2002 10:00:28 +0200
Message-ID: <20020603100028.38dd8a7e.andre.schubert@km3.de> (raw)
Hi all,
i have a simple problem with an sql-update.
Lets say i have a table foo which contains a
ip::inet and to counters inet and local.
And i have a table bar which contains
ip::inet inet and local.
I need these two tables for traffic-accounting.
The table foo should contain the sum of traffic of bar,
therefore once a month i would like to run a script which
performs a query that
selects sum(inet),sum(local) from bar
and
updates foo with these two values where bar.ip = foo.ip.
Who can explain how to perform this action with one query.
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;
Thanks in advance
P.S.: Sorry for my bad english, hope you understand what i mean :)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: andre.schubert@km3.de
Subject: Re: How to update
In-Reply-To: <20020603100028.38dd8a7e.andre.schubert@km3.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox