当我使用这个 mysql 语句时,我总是会得到一个新行而不是更新?
INSERT INTO buyclick SET counter=1, link_id=3
ON DUPLICATE KEY UPDATE
id = LAST_INSERT_ID(id),
counter = counter + 1,
link_id = 3
表结构:
CREATE TABLE `buyclick` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`link_id` int(11) DEFAULT NULL,
`counter` int(11) DEFAULT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `clickeditem` (`link_id`),
KEY `count` (`counter`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;