Yes another ON DUPLICATE KEY UPDATE query
- by Andy Gee
I've been reading all the questions on here but I still don't get it
I have two identical tables of considerable size. I would like to update table packages_sorted with data from packages_sorted_temp without destroying the existing data on packages_sorted
Table packages_sorted_temp contains data on only 2 columns db_id and quality_rank
Table packages_sorted contains data on all 35 columns but quality_rank is 0
The primary key on each table is db_id and this is what I want to trigger the ON DUPLICATE KEY UPDATE with.
In essence how do I merge these two tables by and change packages_sorted.quality_rank of 0 to the quality_rank stored in packages_sorted_temp under the same primary key
Here's what's not working
INSERT INTO `packages_sorted` ( `db_id` , `quality_rank` )
SELECT `db_id` , `quality_rank`
FROM `packages_sorted_temp` ON DUPLICATE
KEY UPDATE `packages_sorted`.`db_id` = `packages_sorted`.`db_id`