Skip site navigation (1) Skip section navigation (2)

How to update an entire table by getting the values from another table?

From: A B <gentosaker(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: How to update an entire table by getting the values from another table?
Date: 2009-08-31 11:43:16
Message-ID: dbbf25900908310443q510816a1sf2f1d0bd63cc3f29@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi. I need to run an update query on a table, and need some help on
how to do it.


I have a table A(id integer primary key, prod_id integer, Y1 integer,
Y2 integer, ... Y14 integer)  and a table B (a integer references A, x
integer,unique(a) );

and now I should set (for each row in A)  prod_id to have the value
that is found in table B

How do I write a statement that does that?

Responses

pgsql-novice by date

Next:From: A. KretschmerDate: 2009-08-31 13:13:37
Subject: Re: How to update an entire table by getting the values from another table?
Previous:From: nextstopsunDate: 2009-08-31 09:44:40
Subject: Problem starting pgsql server on Mac OS X. Pg_hba.conf reading permission.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group