INSERTS and Queries

Started by C Gabout 22 years ago4 messagesgeneral
Jump to latest
#1C G
csgcsg39@hotmail.com

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

#2Russ Brown
postgres@dot4dot.plus.com
In reply to: C G (#1)
Re: INSERTS and Queries

On Mon, 01 Mar 2004 13:36:35 +0000, C G <csgcsg39@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/

#3Nick Barr
nicky@chuckie.co.uk
In reply to: C G (#1)
Re: INSERTS and Queries

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

#4Bill Moran
wmoran@potentialtech.com
In reply to: C G (#1)
Re: INSERTS and Queries

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