Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UkxEO-0005FX-Gb for pgsql-sql@arkaria.postgresql.org; Fri, 07 Jun 2013 14:01:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UkxEO-0008Ap-06 for pgsql-sql@arkaria.postgresql.org; Fri, 07 Jun 2013 14:01:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UkxEM-00089r-Ge for pgsql-sql@postgresql.org; Fri, 07 Jun 2013 14:01:26 +0000 Received: from mail.scanlab.de ([62.138.55.241]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UkxEI-0004U5-8j for pgsql-sql@postgresql.org; Fri, 07 Jun 2013 14:01:26 +0000 Received: from unknown (HELO Exchange-Server.scanlab-intern.de) ([172.16.20.15]) by mail.scanlab-intern.de with ESMTP/TLS/AES128-SHA; 07 Jun 2013 16:01:20 +0200 Received: from Exchange-Server.scanlab-intern.de ([127.0.0.1]) by Exchange-Server ([127.0.0.1]) with mapi; Fri, 7 Jun 2013 16:01:20 +0200 From: Andreas Gaab To: 'JORGE MALDONADO' , "pgsql-sql@postgresql.org" Date: Fri, 7 Jun 2013 16:01:19 +0200 Subject: Re: Advice with an insert query Thread-Topic: [SQL] Advice with an insert query Thread-Index: Ac5jhy5LJ8LrpZDzRPio8Hglm1KlcAAAD5+Q Message-ID: <48DA836F3865C54B8FBF424A3B775AF66817B178CE@Exchange-Server> References: In-Reply-To: Accept-Language: de-DE Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE Content-Type: multipart/alternative; boundary="_000_48DA836F3865C54B8FBF424A3B775AF66817B178CEExchangeServe_" MIME-Version: 1.0 X-Pg-Spam-Score: -0.5 (/) 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 --_000_48DA836F3865C54B8FBF424A3B775AF66817B178CEExchangeServe_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable INSERT INTO table1 (fld1, fld2, fl3) VALUES (SELECT value1, fldx, fldy FROM table2); should work, Andreas Von: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]= Im Auftrag von JORGE MALDONADO Gesendet: Freitag, 7. Juni 2013 15:59 An: pgsql-sql@postgresql.org Betreff: [SQL] Advice with an insert query I need to insert records into a table where one value is fixed and 2 values= come from a SELECT query, something like the following example: INSERT INTO table1 fld1, fld2, fl3 VALUES value1, (SELECT fldx, fldy FROM table2) Is this valid? Respectfully, Jorge Maldonado --_000_48DA836F3865C54B8FBF424A3B775AF66817B178CEExchangeServe_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

INSERT INTO ta= ble1 (fld1, fld2, fl3)

VALUES= (SELECT value1, fldx, fldy FROM table2);

 

should wo= rk,

 <= /p>

Andreas

 <= /p>

 

Von: pgsql-sql-owner@po= stgresql.org [mailto:pgsql-sql-owner@postgresql.org] Im Auftrag von = JORGE MALDONADO
Gesendet: Freitag, 7. Juni 2013 15:59
An: pgsql-sql@postgresql.org
Betreff: [SQL] Advice with an insert = query

 

=

I need to insert records into a table where one value is f= ixed and 2 values come from a SELECT query, something like the following ex= ample:

 

INSERT INTO table1 fld1, fld2, fl3

VALUES value1, (SELECT fldx, fldy FROM table2)

 

=

Is this valid?

 

Respectfully,

Jorge Maldonado

= --_000_48DA836F3865C54B8FBF424A3B775AF66817B178CEExchangeServe_--