X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2116AD1C9DF for ; Wed, 10 Mar 2004 20:03:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 34897-08 for ; Wed, 10 Mar 2004 16:03:39 -0400 (AST) Received: from krogh.officenet.no (cD9089A13.sdsl.catch.no [217.8.154.19]) by svr1.postgresql.org (Postfix) with ESMTP id D2EC2D1C9DB for ; Wed, 10 Mar 2004 16:03:34 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by krogh.officenet.no (Postfix) with ESMTP id 422F213151C for ; Wed, 10 Mar 2004 14:52:24 -0500 (EST) From: Andreas Joseph Krogh Organization: OfficeNet AS To: pgsql-sql@postgresql.org Subject: Inserting data in a table using sub-selects Date: Wed, 10 Mar 2004 20:52:21 +0100 User-Agent: KMail/1.6 MIME-Version: 1.0 Content-Disposition: inline Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <200403102052.21825.andreak@officenet.no> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/115 X-Sequence-Number: 17214 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'd like to fill one table with the contents of another table. Mye sche= ma=20 is like this: CREATE TABLE table1( id serial NOT NULL PRIMARY KEY, title varchar NOT NULL, description varchar ); CREATE TABLE table2( id int NOT NULL REFERENCES(table1(id) ON DELETE CASCADE, content varchar NOT NULL ); Now - is there a way I can do something like: INSERT INTO table2(id, content) values (select t1.id, coalesce(t1.title, ''= )=20 || ' ' || coalesce(t1.description, '') as content from table1 t1); Any hints on how to insert a lot of values at the same time like this? - --=20 Andreas Joseph Krogh Managing Director, Senior Software Developer OfficeNet AS I always do a CVS update before making a patch (unless I forget). gpg public_key: http://dev.officenet.no/~andreak/public_key.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQFAT3H1UopImDh2gfQRAsa6AJ9jZjNz25w4iVnxNJYY9LJuG0HBLACfZfup 1TMzQSi1+YYgNjpcampX6wo=3D =3DfJA3 -----END PGP SIGNATURE-----