From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Alexander Turchin <aturchin(at)chip(dot)org> |
Cc: | PostgreSQL Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: inserting columns with values from a different table |
Date: | 2001-07-09 06:41:19 |
Message-ID: | Pine.BSF.4.21.0107082338230.86282-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, 8 Jul 2001, Alexander Turchin wrote:
> Hello all,
>
> This may be (hopefully) a very basic question, but I (admittedly, a
> pgsql newbie) cannot seem to be able to find an answer to it :(
>
> I have in my database tables, say A, B, and C, all of them referring to
> the same objects (e.g. table A contains customer's name, table B his/her
> purchases, and table C his/her address). I want to create a "master"
> table D whose rows would have some values from table A, some from B, and
> some from C (e.g. name, last purchase, and address). I know I can do an
> INSERT with SELECT - but that will only allow me to insert values from
> one table, not from all three (or more). Is there any way to do this in
> PostgreSQL?
Although you probably really want a view, insert...select should take
values from multiple tables if the select has multiple tables in its from.
insert into table select foo.col1, foo2.col2 from foo,foo2;
seems to work for me.
From | Date | Subject | |
---|---|---|---|
Next Message | Janning Vygen | 2001-07-09 08:03:55 | error handling. How to? |
Previous Message | Frank Miles | 2001-07-09 04:32:45 | Re: inserting columns with values from a different table |