Re: Column names for INSERT with query

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: Robert James <srobertjames(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Column names for INSERT with query
Date: 2013-08-22 22:36:19
Message-ID: CAB8KJ=hhogt_jhksRFZnJ2xjga2VY3PRXEJsUmwe6b2vZusQuQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2013/8/23 Robert James <srobertjames(at)gmail(dot)com>:
> I would like to:
>
> INSERT INTO t
> SELECT * FROM r, (x + y) AS field3
>
> How do I correlate the names of the fields? That is, how do I indicate
> which fields from r or field3 should be inserted into the right
> columns in t?

INSERT INTO t (t_field1, t_field2, t_field3)
SELECT r.field1, r.field2, (x+y)
FROM r

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Don Parris 2013-08-23 00:06:47 Re: Locale Issue
Previous Message bricklen 2013-08-22 22:33:27 Re: Column names for INSERT with query