am 21.09.2005, um 14:36:26 +0200 mailte Joost Kraaijeveld folgendes:
> Hi,
>
> I have an old_table with two columns: "id" and "old_attribute". I have
> new table with the columns "id" and "new_attribute".
There are indexes on id?
> Is that possible in a SQL script (pgadmin or psql console?) and if so,
> what is the syntax in this example?
Yes, of course.
>
> 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
Error, because i don't need a insert on new_table. You need a update!
(If there a primary index on id this will raise a error)
update t_new set name = (select name from t_old) where t_old.id=t_new.id;
(t_old and t_new are the tables with (id, name) similar your example)
Regards, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net=== Schollglas Unternehmensgruppe ===