From: | Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl> |
---|---|
To: | "Pgsql-sql(at)postgresql(dot)org" <Pgsql-sql(at)postgresql(dot)org> |
Subject: | How to add column from old_table to new_table? |
Date: | 2005-09-21 12:36:26 |
Message-ID: | 1127306186.20038.21.camel@Panoramix |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
I have an old_table with two columns: "id" and "old_attribute". I have
new table with the columns "id" and "new_attribute".
old_table and new_table contain exactly the same id's. Now I want to
copy all the old_attribute from old_table to the corresponding
new_attribute in the new_table
Is that possible in a SQL script (pgadmin or psql console?) and if so,
what is the syntax in this example?
I have tried something as:
insert into new_table(new_attribute)
value( select old_attribute from old_table, new_table where old_table.id
= new_table_id)
where new_table.id = old_table.id
TIA
--
Groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J(dot)Kraaijeveld(at)Askesis(dot)nl
web: www.askesis.nl
From | Date | Subject | |
---|---|---|---|
Next Message | Joost Kraaijeveld | 2005-09-21 12:50:55 | Re: How to add column from old_table to new_table? |
Previous Message | Achilleus Mantzios | 2005-09-21 06:23:13 | Re: Inheritance (general hints wanted) |