Friday, 30 June 2017

“INSERT IGNORE” vs “INSERT … ON DUPLICATE KEY UPDATE”

In case you want to see what this all means, here is a blow-by-blow of everything:CREATE TABLE `users_partners` (  `uid` int(11) NOT NULL DEFAULT '0',  `pid` int(11) NOT NULL DEFAULT '0',  PRIMARY KEY (`uid`,`pid`),  KEY `partner_user` (`pid`,`uid`)) ENGINE=MyISAM DEFAULT CHARSET=utf8Primary key is based on both columns of this quick reference table. A Primary key requires unique values.Let's begin:INSERT INTO users_partners (uid,pid) VALUES (1,1);...1 row(s) affectedINSERT INTO users_partners (uid,pid) VALUES (1,1);...Error...