如果该对不存在,我如何插入一行?
* 注意这些不是主键,我的主键设置为自动递增
尝试插入忽略但不起作用
INSERT IGNORE INTO mytable (`myid`, `theirid`) VALUES ('5', '1')
ON DUPLICATE KEY <DO NOTHING>
表看起来像:
CREATE TABLE `mytable` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`myid` bigint(20) NOT NULL,
`theirid` bigint(20) NOT NULL,
`activated` tinyint(1) NOT NULL DEFAULT '0',
`dateStamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1$$