transfer data

From: Detlef Jockheck <detlef(at)jockheck(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: transfer data
Date: 2003-04-08 17:17:24
Message-ID: 200304081717.h38HHOY02431@krakatau.jockheck.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

I have two tables:

Table A:
article_number, count
a 2
b 5
g 3

Table B:
article_number, count
b 7

Now I want to transfer 2 units of b and 3 units of g from Table A to table
B. So the result should be:

Table A:
article_number, count
a 2
b 3
g 0 (or empty line)

Table B:
article_number, count
b 9
g 3

What is the best way to do this transaction with postgresql? I've tried to do
this with update and insert statements from psql but I'm sure there is a
better way!?

ciao
Detlef

--
# Dipl. Ing. (FH) Detlef Jockheck
# E-mail: detlef(at)jockheck(dot)de
# -------------------------------

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dennis Gearon 2003-04-08 17:38:03 Re: transfer data
Previous Message Doug McNaught 2003-04-08 16:28:24 Re: How can I indicate the readline location ???