Why are 2 rows affected in my `INSERT … ON DUPLICATE KEY UPDATE`?

前端 未结 2 1685
无人共我
无人共我 2020-12-07 19:29

I\'m doing an INSERT ... ON DUPLICATE KEY UPDATE for a PRIMARY KEY in the following table:

DESCRIBE users_interests;
相关标签:
2条回答
  • 2020-12-07 20:16

    From the manual:

    With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row and 2 if an existing row is updated.

    0 讨论(0)
  • 2020-12-07 20:21

    So you know whether you updated a row (duplicate key) or just inserted one: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

    0 讨论(0)
提交回复
热议问题