Let's say for instance:
I have two tables: old_data and new_data.
Both old_data and new_data have one column called this_is_col.
Both old_data and new_data have various (hundreds) of rows of dates (2010-02-06, 2010-01-09, 2007-06-02, etc.). Both tables don't necessarily have the same dates, but they both have the same format.
The fields of both tables are various integers.
My task:
Copy the fields from old_data to new_data.
If a date exists in both tables, the field in new_data will be replaced.
If the date doesn't exist in new_data, then the correct row will be added and the field will be copied over.
Here is how far I've gotten:
Create a temporary column:
ALTER TABLE `new_data` ADD `tempColumn` TEXT NULL;
Copy over data from old_data:
INSERT INTO `new_data` (`tempColumn`) SELECT `this_is_col` FROM `old_data`;
Combine temporary column and new_data . this_is_col. (I haven't really figured this step out since I haven't gotten this far).
MERGE? `tempColumn` `this_is_col`;
Delete temporary table
ALTER TABLE `new_data` DROP `tempColumn`;
Upon performing the second action (transferring the data over to the temporary column) I get this error:
#1062 - Duplicate entry '0000-00-00' for key 1
And now I'm stuck. Any help would be appreciated. I'm using MySQL and phpMyAdmin to test the SQL commands.