pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Gaab <A.Gaab@scanlab.de>
To: JORGE MALDONADO <jorgemal1960@gmail.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Advice with an insert query
Date: Fri, 7 Jun 2013 16:01:19 +0200
Message-ID: <48DA836F3865C54B8FBF424A3B775AF66817B178CE@Exchange-Server> (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>

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

view thread (4+ messages)  latest in thread

Message-ID: <48DA836F3865C54B8FBF424A3B775AF66817B178CE@Exchange-Server>
Permalink:  ../48DA836F3865C54B8FBF424A3B775AF66817B178CE@Exchange-Server/
Also on:    postgresql.org/message-id/48DA836F3865C54B8FBF424A3B775AF66817B178CE@Exchange-Server

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: A.Gaab@scanlab.de, jorgemal1960@gmail.com
  Subject: Re: Advice with an insert query
  In-Reply-To: <48DA836F3865C54B8FBF424A3B775AF66817B178CE@Exchange-Server>

* 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