Re: Advice with an insert query

From: Oliver d'Azevedo Cristina <oliveiros(dot)cristina(at)gmail(dot)com>
To: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Advice with an insert query
Date: 2013-06-07 14:06:58
Message-ID: 6B78B72D-0B1E-4CBC-A9D5-9029A5C4CED5@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Kellerer 2013-06-07 14:26:49 Re: Advice with an insert query
Previous Message Andreas Gaab 2013-06-07 14:01:19 Re: Advice with an insert query