Click here to Skip to main content
15,886,074 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
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...
Posted
Updated 19-Aug-15 21:46pm
v2

You have to define the list of columns to copy between tables.

SQL
INSERT INTO DestinationTable (<ListOfColumns>)
SELECT <ListOfColumns>
FROM SourceTable


For further information, please see: 13.2.5.1 INSERT ... SELECT Syntax[^]
 
Share this answer
 
Comments
DamithSL 20-Aug-15 3:52am    
beat me to it, 5wd
Maciej Los 20-Aug-15 3:53am    
Thank you.
give column names as below
SQL
INSERT INTO ems_db1.drtu_d1 (col1, col2, ..., coln)
SELECT col1, col2, ..., coln
FROM ems_db_to_drtu_d10 
WHERE Device_ID='DRTU_D10';
 
Share this answer
 
Comments
Maciej Los 20-Aug-15 3:53am    
5ed!
ven.in 20-Aug-15 4:15am    
is there any other way to do this? becoz i did with this, its 52 columns to specifies... so any other way??
DamithSL 20-Aug-15 4:19am    
Sorry

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900