From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | sarlav kumar <sarlavk(at)yahoo(dot)com> |
Cc: | pgsqlperform <pgsql-performance(at)postgresql(dot)org>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: INSERT question |
Date: | 2004-12-13 16:49:52 |
Message-ID: | 20041213164952.GC546@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice pgsql-performance |
On Mon, Dec 13, 2004 at 08:28:39 -0800,
sarlav kumar <sarlavk(at)yahoo(dot)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
;
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2004-12-13 17:21:03 | Re: Get comment |
Previous Message | Tom Lane | 2004-12-13 16:48:14 | Re: INSERT question |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Nunes Melo | 2004-12-13 17:17:49 | Similar tables, different indexes performance |
Previous Message | Tom Lane | 2004-12-13 16:48:14 | Re: INSERT question |