Check out example codes for "mysql insert on dupèlicate". 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;

Learn ReactJs, React Native from akashmittal.com