pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAdvice with an insert query
4+ messages / 4 participants
[nested] [flat]
* Advice with an insert query
@ 2013-06-07 13:58 JORGE MALDONADO <jorgemal1960@gmail.com>
2013-06-07 14:01 ` Re: Advice with an insert query Andreas Gaab <A.Gaab@scanlab.de>
2013-06-07 14:06 ` Re: Advice with an insert query Oliver d'Azevedo Cristina <oliveiros.cristina@gmail.com>
2013-06-07 14:26 ` Re: Advice with an insert query Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 3 replies; 4+ messages in thread
From: JORGE MALDONADO @ 2013-06-07 13:58 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Advice with an insert query
2013-06-07 13:58 Advice with an insert query JORGE MALDONADO <jorgemal1960@gmail.com>
@ 2013-06-07 14:01 ` Andreas Gaab <A.Gaab@scanlab.de>
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Gaab @ 2013-06-07 14:01 UTC (permalink / raw)
To: JORGE MALDONADO <jorgemal1960@gmail.com>; pgsql-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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Advice with an insert query
2013-06-07 13:58 Advice with an insert query JORGE MALDONADO <jorgemal1960@gmail.com>
@ 2013-06-07 14:06 ` Oliver d'Azevedo Cristina <oliveiros.cristina@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Oliver d'Azevedo Cristina @ 2013-06-07 14:06 UTC (permalink / raw)
To: JORGE MALDONADO <jorgemal1960@gmail.com>; +Cc: pgsql-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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Advice with an insert query
2013-06-07 13:58 Advice with an insert query JORGE MALDONADO <jorgemal1960@gmail.com>
@ 2013-06-07 14:26 ` Thomas Kellerer <spam_eater@gmx.net>
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Kellerer @ 2013-06-07 14:26 UTC (permalink / raw)
To: pgsql-sql
JORGE MALDONADO, 07.06.2013 15:58:
> 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
INSERT INTO table1 (fld1, fld2, fl3)
SELECT value1, fldx, fldy
FROM table2
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2013-06-07 14:26 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-06-07 13:58 Advice with an insert query JORGE MALDONADO <jorgemal1960@gmail.com>
2013-06-07 14:01 ` Andreas Gaab <A.Gaab@scanlab.de>
2013-06-07 14:06 ` Oliver d'Azevedo Cristina <oliveiros.cristina@gmail.com>
2013-06-07 14:26 ` Thomas Kellerer <spam_eater@gmx.net>
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