Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UkxFx-0005K8-Ex for pgsql-sql@arkaria.postgresql.org; Fri, 07 Jun 2013 14:03:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UkxFw-00011c-H3 for pgsql-sql@arkaria.postgresql.org; Fri, 07 Jun 2013 14:03:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UkxFn-0000uM-6a for pgsql-sql@postgresql.org; Fri, 07 Jun 2013 14:02:55 +0000 Received: from mail-ea0-x235.google.com ([2a00:1450:4013:c01::235]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UkxFg-0004Uc-60 for pgsql-sql@postgresql.org; Fri, 07 Jun 2013 14:02:54 +0000 Received: by mail-ea0-f181.google.com with SMTP id a15so1182399eae.40 for ; Fri, 07 Jun 2013 07:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; bh=wAEXhSx3HMeIj7l7Z1pjmfCVDBdB9xgnvSA9WrLqE2k=; b=gADajZzsh+nWEcQB2aEoSBEYoytHpKe1tFlsGIcslC4YqLxh9sfx1+R7SyWH9Nhy+b A0BgIwdNf5NDA8AacfdQc0EsKXQCJSjAGjIiOi5j7g2KZRjDDTYgXGnu+Kg2zINMeiMl lnW6gCWPhj5rf01aL31Ufu39jEqq4SWyKYaZaSk7GRsldLIxxWls+GRi3TvTWhhmWd4d N3G0e8xVC6s0ipVvLsxPbRRTLi0Z7cGxiqdd/yHupGeXV+e0rgkroNlnCCxT+q/Yl6E+ ONbte18svrYNX1NONIPEOIPjIv6jpFSB0PaT+9v9hwEpc0wjq8ofvWm0DpVdbgzkc1fK G/Sw== X-Received: by 10.14.115.1 with SMTP id d1mr15759032eeh.27.1370613767130; Fri, 07 Jun 2013 07:02:47 -0700 (PDT) Received: from [10.35.5.159] (6.27.136.95.rev.vodafone.pt. [95.136.27.6]) by mx.google.com with ESMTPSA id c5sm96494274eeu.8.2013.06.07.07.02.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Jun 2013 07:02:46 -0700 (PDT) References: In-Reply-To: Mime-Version: 1.0 (iPhone Mail 8L1) Content-Transfer-Encoding: 7bit Content-Type: multipart/alternative; boundary=Apple-Mail-1--682679955 Message-Id: <6B78B72D-0B1E-4CBC-A9D5-9029A5C4CED5@gmail.com> Cc: "pgsql-sql@postgresql.org" X-Mailer: iPhone Mail (8L1) From: Oliver d'Azevedo Cristina Subject: Re: Advice with an insert query Date: Fri, 7 Jun 2013 15:06:58 +0100 To: JORGE MALDONADO X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org --Apple-Mail-1--682679955 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Just pass the fixed value for inside the select subquery.=20 Do this > INSERT INTO table1 fld1, fld2, fl3 > VALUES (SELECT value1, fldx, fldy FROM table2) HTH Best, Oliver=20 Enviado via iPhone Em 07/06/2013, =C3=A0s 02:58 PM, JORGE MALDONADO es= creveu: > I need to insert records into a table where one value is fixed and 2 value= s come from a SELECT query, something like the following example: >=20 > INSERT INTO table1 fld1, fld2, fl3 > VALUES value1, (SELECT fldx, fldy FROM table2) >=20 > Is this valid? >=20 > Respectfully, > Jorge Maldonado --Apple-Mail-1--682679955 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Just pass the fixed value for inside th= e select subquery. 
Do this

INSERT INTO table1 fld1, fld2, fl3
VALUES  (SELECT = ;value1, fldx, fldy FROM table2)

=
HTH

Best,
Oliver=  



Enviado via iPhone
Em 07/06/2013, =C3=A0s 02:58 PM, JORGE MALDONADO <jorgemal1960@gmail.com> escreveu:

<= div>
I need to insert records into a ta= ble where one value is fixed and 2 values come from a SELECT query, somethin= g like the following example:

INSERT I= NTO table1 fld1, fld2, fl3
VALUES value1, (SELECT fldx, fldy FROM table2)

Is this= valid?

=
Respectfull= y,
Jorge Maldonado
= --Apple-Mail-1--682679955--