当两个列具有不同的列时,从一个表复制到另一个表 [英] copy from one table to other when both having different number of columns
本文介绍了当两个列具有不同的列时,从一个表复制到另一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
insert into ems_db1.drtu_d1 选择 * 来自 ems_db_to_drtu_d10 其中 Device_ID = ' DRTU_D10'
这是mysql查询表 ems_db1.drtu_d1
有73列,表 ems_db_to_drtu_d10
有52列。上面的查询给出错误bcoz的count不匹配。请告诉我是否有任何方法可以做到这一点。谢谢......
解决方案
你必须定义要在表之间复制的列列表。
INSERT INTO DestinationTable(< ListOfColumns> )
SELECT < ListOfColumns>
FROM SourceTable
详情请见: 13.2.5.1 INSERT ... SELECT语法 [ ^ ]
给出如下列名称
INSERT INTO ems_db1.drtu_d1(col1,col2,...,coln)
SELECT col1,col2,...,coln
FROM ems_db_to_drtu_d10
WHERE Device_ID = ' DRTU_D10' 跨度>;
insert into ems_db1.drtu_d1 select * from ems_db_to_drtu_d10 where Device_ID='DRTU_D10'
this is mysql query table ems_db1.drtu_d1
having 73 columns and table ems_db_to_drtu_d10
having 52 columns. above query give error bcoz of count doesn't match. plz tell me if any way to make this. thank you...
解决方案
You have to define the list of columns to copy between tables.
INSERT INTO DestinationTable (<ListOfColumns>) SELECT <ListOfColumns> FROM SourceTable
For further information, please see: 13.2.5.1 INSERT ... SELECT Syntax[^]
give column names as below
INSERT INTO ems_db1.drtu_d1 (col1, col2, ..., coln) SELECT col1, col2, ..., coln FROM ems_db_to_drtu_d10 WHERE Device_ID='DRTU_D10';
这篇关于当两个列具有不同的列时,从一个表复制到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文