Check out example codes for "mysql on duplicate key update". It will help you in understanding the concepts better.

Code Example 1

INSERT INTO table_name(c1)
VALUES(c1)
ON DUPLICATE KEY UPDATE c1 = VALUES(c1) + 1;

Code Example 2

INSERT INTO t1 (a,b,c) VALUES (1,2,3)
  ON DUPLICATE KEY UPDATE c=3;
INSERT INTO t1 (a,b,c) VALUES (4,5,6)
  ON DUPLICATE KEY UPDATE c=9;

Code Example 3

UPDATE t1 SET c=c+1 WHERE a=1 OR b=2 LIMIT 1;

Learn ReactJs, React Native from akashmittal.com