MySQL insert or update if exists in one query

INSERT INTO `table` (`id`, `field_1`, `field_2`) VALUES(1, "value1", "value2") ON DUPLICATE KEY UPDATE
 `field_1`="value1", `field_2`="value2"

Leave a Reply

Your email address will not be published. Required fields are marked *