From: | Nick Barr <nicky(at)chuckie(dot)co(dot)uk> |
---|---|
To: | C G <csgcsg39(at)hotmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: INSERTS and Queries |
Date: | 2004-03-01 13:49:16 |
Message-ID: | 40433F5C.8020900@chuckie.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
C G wrote:
> Dear All,
>
> I can use insert with 'select' if I do this
>
> INSERT INTO TABLE t1 (col1) SELECT stuff FROM t2;
>
> But I want to insert more than one thing into the table, e.g.
>
> INSERT INTO TABLE t1 (col1,col2) SELECT stuff FROM t2 , 100;
>
> Any ideas on how I would achieve this?
>
> Thanks
>
> Colin
>
> _________________________________________________________________
> Express yourself with cool emoticons - download MSN Messenger today!
> http://www.msn.co.uk/messenger
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
The SELECT clause can be any ordinary SELECT clause, that can return
multiple columns from a table. So for example:
INSERT INTO table (col1, col2) SELECT col1, col2 from table2;
Also, just like standard SELECT statements, the following would also work:
INSERT INTO table (col1, col2) SELECT col1, 100 FROM table2;
HTH
Nick
From | Date | Subject | |
---|---|---|---|
Next Message | Bill Moran | 2004-03-01 13:56:46 | Re: INSERTS and Queries |
Previous Message | Russ Brown | 2004-03-01 13:44:27 | Re: INSERTS and Queries |