By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,590 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,590 IT Pros & Developers. It's quick & easy.

INSERTS and Queries

P: n/a
C G
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

Nov 23 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
On Mon, 01 Mar 2004 13:36:35 +0000, C G <cs******@hotmail.com> 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?
INSERT INTO TABLE t1 (col1,col2) SELECT stuff, 100 FROM t2;

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


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #2

P: n/a
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


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #3

P: n/a
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?


INSERT INTO TABLE t1 (col1, col2) SELECT stuff, morestuff FROM t2;

If you want to instert some constant:

INSERT INTO TABLE t1 (col1, col2) SELECT stuff, 100 FROM t2;

--
Bill Moran
Potential Technologies
http://www.potentialtech.com
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.