pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver d'Azevedo Cristina <oliveiros.cristina@gmail.com>
To: JORGE MALDONADO <jorgemal1960@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Advice with an insert query
Date: Fri, 7 Jun 2013 15:06:58 +0100
Message-ID: <6B78B72D-0B1E-4CBC-A9D5-9029A5C4CED5@gmail.com> (raw)
In-Reply-To: <CAAY=A7-4fNtC-6akfvfBw2VmqAS0B5+bVxHktWg2qMztV21KEA@mail.gmail.com>
References: <CAAY=A7-4fNtC-6akfvfBw2VmqAS0B5+bVxHktWg2qMztV21KEA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Just pass the fixed value for inside the 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, às 02:58 PM, JORGE MALDONADO <jorgemal1960@gmail.com> escreveu:

> 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

view thread (4+ messages)  latest in thread

Message-ID: <6B78B72D-0B1E-4CBC-A9D5-9029A5C4CED5@gmail.com>
Permalink:  ../6B78B72D-0B1E-4CBC-A9D5-9029A5C4CED5@gmail.com/
Also on:    postgresql.org/message-id/6B78B72D-0B1E-4CBC-A9D5-9029A5C4CED5@gmail.com

reply

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-sql@postgresql.org
  Cc: oliveiros.cristina@gmail.com, jorgemal1960@gmail.com
  Subject: Re: Advice with an insert query
  In-Reply-To: <6B78B72D-0B1E-4CBC-A9D5-9029A5C4CED5@gmail.com>

* 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