Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select into

Status
Not open for further replies.

doddo

Programmer
Feb 14, 2001
37
GB

Hi, I want to copy some columns from a table into another table as in:

select table.column1,table.column2 into table_new from table

Mysql doesn't seem to support 'select into's' other than for exporting. Does anybody have a work around?

cheers
 
Try this:

Code:
CREATE TABLE table_new
SELECT table.column1, table.column2
FROM table;

Hope this helps
-Rob
 
thanks, but I meant for adding rows to a table from the result of a select as opposed to creating a new one.

I guess I could create a new one from the old one plus the additional rows but that would mean each time i performed the update I would have to change the name

i.e
create table_2 from update_table and table_1
create table_3 from update_table and table_2
create table_4 from update_table and table_3

cheers
 
Ah, apologies. Maybe you need
Code:
INSERT INTO table_new(column1,column2)
SELECT column1, column2
FROM table;
Hope this is more appropriate for your purposes
-Rob
 

yes that would do it. I didn't expect it to work as it's kind of nested

cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top