开发者

mysql duplicate record field

开发者 https://www.devze.com 2023-01-27 05:52 出处:网络
Is there a way to overwrite or skip duplicate records? 1062 - Duplicate entry \'2\' for key 1 is there a way to add : insert on duplicate key update to开发者_开发技巧 a sql file that only has insert?H

Is there a way to overwrite or skip duplicate records?

1062 - Duplicate entry '2' for key 1

is there a way to add : insert on duplicate key update to开发者_开发技巧 a sql file that only has insert?


Have a look at 12.2.5.1. INSERT ... SELECT Syntax and 12.2.5. INSERT Syntax

And look for

Specify IGNORE to ignore rows that would cause duplicate-key violations.


try this:

INSERT ON DUPLICATE KEY UPDATE 

Although usually people forget to put the autoincrement field for the id and thus the error.

0

精彩评论

暂无评论...
验证码 换一张
取 消