如何将行从一个表复制到另一个表?

时间:2010-05-12 18:08:02

标签: sql mysql database

我有2个具有相同结构的表我需要从一个表中选择数据并且必须存储到第二个表中。

4 个答案:

答案 0 :(得分:15)

insert into tablea(id,name) select id,name from tableb;

答案 1 :(得分:8)

因为它们是相同的结构,所以你可以做到


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

答案 2 :(得分:6)

省略值关键字

insert into tbl1 
select * from tbl2

答案 3 :(得分:6)

insert into blacklist 
select * 
from newblacklist

用于上传任何单个号码

insert into blacklist 
select * 
from newblacklist 
where numbers ='123456'