츨처:https://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html
mysql> create table test3 (a int primary key, b int ,c int);
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO test3 (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
Query OK, 1 row affected (0.01 sec)
mysql> select * from test3;
+---+------+------+
| a | b | c |
+---+------+------+
| 1 | 2 | 3 |
+---+------+------+
1 row in set (0.00 sec)
mysql> INSERT INTO test3 (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
Query OK, 2 rows affected (0.00 sec)
mysql> select * from test3;
+---+------+------+
| a | b | c |
+---+------+------+
| 1 | 2 | 4 |
+---+------+------+
1 row in set (0.00 sec)
mysql> INSERT INTO test3 (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
Query OK, 2 rows affected (0.00 sec)
mysql> select * from test3;
+---+------+------+
| a | b | c |
+---+------+------+
| 1 | 2 | 5 |
+---+------+------+
1 row in set (0.00 sec)