在 MySQL 中将行从一个表复制到另一个表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2821517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:02:17 来源:igfitidea点击:
Copy rows from one table to another in MySQL
提问by TinTin
I have two tables with the same structure. I need to select data from one table and have to store them into the other.
我有两个结构相同的表。我需要从一个表中选择数据并将它们存储到另一个表中。
How can I do that?
我怎样才能做到这一点?
回答by Tim Hoolihan
insert into tablea(id,name) select id,name from tableb;
回答by Garett
Since they are the same structure then you can just do
由于它们的结构相同,因此您可以这样做
insert into table1 select colum1, column2,... from table2
回答by Charles Bretana
leave out the values keyword
省略 values 关键字
insert into tbl1
select * from tbl2
回答by Rizwan Basheer
insert into blacklist
select *
from newblacklist
for uploading any single number
用于上传任何单个号码
insert into blacklist
select *
from newblacklist
where numbers ='123456'