From: Bruno Wolff III <bruno@wolff.to>
To: sarlav kumar <sarlavk@yahoo.com>
Cc: pgsqlperform <pgsql-performance@postgresql.org>
Cc: pgsql-novice@postgresql.org
Subject: Re: INSERT question
Date: Mon, 13 Dec 2004 10:49:52 -0600
Message-ID: <20041213164952.GC546@wolff.to> (raw)
In-Reply-To: <20041213162839.60931.qmail@web51303.mail.yahoo.com>
References: <20041213162839.60931.qmail@web51303.mail.yahoo.com>
On Mon, Dec 13, 2004 at 08:28:39 -0800,
sarlav kumar <sarlavk@yahoo.com> 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
;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: bruno@wolff.to, sarlavk@yahoo.com, pgsql-novice@postgresql.org
Subject: Re: INSERT question
In-Reply-To: <20041213164952.GC546@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox