Say I have a table (lets call it DB10) which has 10 columns. I have another table with 15 columns (DB15), 10 of which are identical to the columns in DB10 in terms of name and data type.
I want to insert all the columns in DB10 into DB15. I have tried using the following:
INSERT INTO DB15 SELECT * FROM DB10
But this gives me Error Code 1136 "Column count doesn't match value count at row 1". From what I understand through research is that its trying to map 10 values to 15 columns.
So my question is, how is this possible without having to enter the individual columns. Can I perhaps use a function to make it assume a value of null for columns that can't be mapped?
The reason I want to do this? I have more than 10 columns to be mapped, and I just want to simplify the SQL script, smaller scripts are easier to check.
I've done my research and found this question here: INSERT into Table On Columns That Exist
It seems like the guy wants essentially the same thing done, but he 's trying to perform it on multiple linked tables and arrays, I couldn't follow how I could apply it to my case.