Like:
INSERT INTO `video_play_counts`
(`id`,`video_id`,`date`,`count`,`created`,`modified`)
VALUES
("",1,"2016-12-01",26,"2016-12-03 17:51:53","2016-12-03 17:51:53")
ON DUPLICATE KEY UPDATE
`count` = GREATEST(`count`,VALUES(`count`)),
`modified` = IF(VALUES(`count`) > `count`,VALUES(`modified`),`modified`)
So, I have a unique key on video_id and date and when I make an UPDATE on this unique key, in the case that the new count value is bigger the existing one, I would like to also update the modified field accordingly. The count field updates as expected but the modified field does not get the new value in the case of an UPDATE.
Please note that I'm using this to do multiple insert/update in one query, just in this example it has only one set of values.
What am I doing wrong ?
Aucun commentaire:
Enregistrer un commentaire