X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 90FFA3A62A7 for ; Mon, 13 Dec 2004 16:37:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81295-10 for ; Mon, 13 Dec 2004 16:37:13 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 6B18A3A6174 for ; Mon, 13 Dec 2004 16:37:12 +0000 (GMT) Received: (qmail 1831 invoked by uid 500); 13 Dec 2004 16:49:52 -0000 Date: Mon, 13 Dec 2004 10:49:52 -0600 From: Bruno Wolff III To: sarlav kumar Cc: pgsqlperform , pgsql-novice@postgresql.org Subject: Re: INSERT question Message-ID: <20041213164952.GC546@wolff.to> Mail-Followup-To: sarlav kumar , pgsqlperform , pgsql-novice@postgresql.org References: <20041213162839.60931.qmail@web51303.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041213162839.60931.qmail@web51303.mail.yahoo.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.106 tagged_above=0 required=5 tests=AWL, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200412/82 X-Sequence-Number: 11659 On Mon, Dec 13, 2004 at 08:28:39 -0800, sarlav kumar wrote: > > Is there a way to write the INSERT as follows? > > INSERT into merchant_buyer_country (merchant_id,country,enabled,group_id) values (1203, > (SELECT code FROM country WHERE send IS NOT NULL OR receive IS NOT NULL), 'true',1); > You have to use a SELECT instead of the VAlues clause. Something like the following should work: INSERT INTO merchant_buyer_country (merchant_id, country, enabled, group_id) SELECT 1203, code, TRUE, 1 FROM country WHERE send IS NOT NULL OR receive IS NOT NULL ;