views:

79

answers:

3

I have 2 table with same struture i need to select data from one table and have to store in to 2nd table.

+2  A: 

leave out the values keyword

insert into tbl1 
select * from tbl2
Charles Bretana
you don't want to let the db engine assume field order, be explicit
Tim Hoolihan
+8  A: 
insert into tablea(id,name) select id,name from tableb;
Tim Hoolihan
A: 

Since they are the same structure then you can just do


insert into table1 select colum1, column2,... from table2
Garett