My table before the insert (Table name is ds_answer)
===============================================================================
answer_id | member_id | question_id | msgstr | type | tstamp
===============================================================================
50 2 176 aaaa show 2014-07-27 12:11:12
51 2 177 bbbb show 2014-07-27 12:12:23
52 2 180 cccc show 2014-07-27 12:12:50
===============================================================================
Query command ::
INSERT INTO `ds_answer` (`member_id`, `question_id` , `msgstr` , `type`)
VALUES ('2', '180' , 'dddssds' , 'show' )
ON DUPLICATE KEY UPDATE msgstr = 'dddssds'
It's not working. MySQL added row every time. But It isn't update msgstr column in answer_id = 52.
How to fix this problem?
on duplicatestuff?insert ... on duplicatedoesn't check if there actually is a unique index. it'll try the insert no matter what, but the on dupe stuff just won't ever trigger.