Re: How to add column from old_table to new_table?
От
A. Kretschmer
Тема
Re: How to add column from old_table to new_table?
Дата
Msg-id
20050921125625.GB21483@webserv.wug-glas.de
Ответ на
How to add column from old_table to new_table? (Joost Kraaijeveld)
Список
Дерево обсуждения
How to add column from old_table to new_table? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
Re: How to add column from old_table to new_table? "Joost Kraaijeveld" <J.Kraaijeveld@Askesis.nl>
Re: How to add column from old_table to new_table? Gnanavel S <s.gnanavel@gmail.com>
Re: How to add column from old_table to new_table? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
Re: How to add column from old_table to new_table? "A. Kretschmer" <akretschmer@despammed.com>
Re: How to add column from old_table to new_table? "A. Kretschmer" <akretschmer@despammed.com>
Re: How to add column from old_table to new_table? Thomas Pundt <mlists@rp-online.de>
Re: How to add column from old_table to new_table? "Leif B. Kristensen" <leif@solumslekt.org>
Re: How to add column from old_table to new_table? Gnanavel S <s.gnanavel@gmail.com>
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 ===
В списке pgsql-sql по дате отправления