I want to add a row to a database table, but if a row exists with the same unique key I want to update the row.
For example:
INSERT IGNORE INTO table (id, name, age) VALUES (1, "A", 19);
INSERT INTO TABLE (id, name, age) VALUES(1, "A", 19) ON DUPLICATE KEY UPDATE NAME = "A", AGE = 19;
REPLACE INTO table (id, name, age) VALUES(1, "A", 19);
All these solution will work regarding your question.
If you want to know in details regarding these statement visit this link