Update record if exists, else write new record


Query:

 INSERT INTO upsert_table(id, name, value) VALUES(4,"Check_Upsert",888) ON DUPLICATE KEY UPDATE name = VALUES(name), value = VALUES(value);

If id=4 already there in table it will update values else write the new record in table

Advertisements