MySQL从一个数据库插入另一个数据库 [英] MySQL Insert Into from one Database in another
本文介绍了MySQL从一个数据库插入另一个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将数据从一个数据库迁移到另一个数据库,两者都在同一个本地系统上。
表和列有不同的名称,我不能从旧数据库迁移所有列,所以
选择*
不适用于我。 >
INSERT INTO newDatabase.table1(Column1,Column2);
SELECT oldDatabase.table1(column1,column2)FROM oldDatabase.table1
是一个#1064 - 语法错误
我的查询中的错误是什么, / p>
提前感谢
解决方案
/ p>
INSERT INTO newDatabase.table1(Column1,Column2)
SELECT column1,column2 FROM oldDatabase.table1;
I need to migrate data from one Database to another one, both are on the same local system.
The tables and columns got different names and I mustn't migrate all the Columns from the old Database, so
Select *
doesn't work for me.
INSERT INTO newDatabase.table1(Column1, Column2);
SELECT oldDatabase.table1(column1, column2) FROM oldDatabase.table1
but all i got is a #1064 - Syntax Error
What is the error in my Query and How can i fix this ?
Thanks in advance
解决方案
Your query should go like this:
INSERT INTO newDatabase.table1 (Column1, Column2)
SELECT column1, column2 FROM oldDatabase.table1;
这篇关于MySQL从一个数据库插入另一个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文