I'm doing an INSERT ... ON DUPLICATE KEY UPDATE
for a PRIMARY KEY
in the following table:
mysql> describe users_interests;
+------------+---------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------------------------+------+-----+---------+-------+
| uid | int(11) | NO | PRI | NULL | |
| iid | int(11) | NO | PRI | NULL | |
| preference | enum('like','dislike','ignore') | YES | | NULL | |
+------------+---------------------------------+------+-----+---------+-------+
However, even though these values should be unique, I'm seeing 2 rows affected.
mysql> insert into users_interests (uid, iid, preference) values (2, 2, 'like')
on duplicate key update preference='like';
Query OK, 2 rows affected (0.04 sec)
Why is this happening?
EDIT
For comparison, see this query:
mysql> update users_interests set preference='like' where uid=2 and iid=2;
Query OK, 1 row affected (0.44 sec)
Rows matched: 1 Changed: 1 Warnings: 0