SQL update on duplicate key update
问题 I have asked this question Grouping and update large database table, but I didn't get the answer for this. I have a table: name, date, detail, no , and name, date, detail are together as PK. Somehow I need to update detail , and it is possible that there are duplicate key. Thus I need to sum the no for the duplicate rows. ON DUPLICATE KEY UPDATE is only used for INSERT . So how to address this problem? 回答1: First things first, that multi-column primary key is probably a bad idea; as you've