insert into hi_user_score set hello_id=74372073,a=10001 on duplicate key update hello_id=74372073, a=10001

insert into hi_user_score set hello_id=74372073,a=10001 on duplicate key update hello_id=74372073, a=10001



如果在INSERT语句末尾指定了ON DUPLICATE KEY UPDATE,并且插入行后会导致在一个UNIQUE索引或PRIMARY KEY中出现重复值,则在出现重复值的行执行UPDATE;如果不会导致唯一值列重复的问题,则插入新行。 



如果行作为新记录被插入,则受影响行的值显示1;如果原有的记录被更新,则受影响行的值显示2。



添加数据时会出现PRIMARY KEY不唯一,那么就修改
原文地址:https://www.cnblogs.com/bjfy/p/5694427.html