Re: INSERT question - Mailing list pgsql-novice

From Tom Lane
Subject Re: INSERT question
Date
Msg-id 25641.1102956494@sss.pgh.pa.us
Whole thread Raw
In response to INSERT question  (sarlav kumar <sarlavk@yahoo.com>)
Responses Re: INSERT question
List pgsql-novice
sarlav kumar <sarlavk@yahoo.com> writes:
> 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);

> I tried this, but I get the following problem:
> ERROR:  More than one tuple returned by a subselect used as an expression.

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;

            regards, tom lane

pgsql-novice by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: INSERT question
Next
From: Michael Fuhr
Date:
Subject: Re: Get comment