Same Query we can do the insert and update process in mysql
For Example:
Consider following query if key id is '1' existing table it will perform update query like second query. otherwise it will insert as new record.
INSERT INTO product (id,name,price) VALUES (1,'jeeva','$100')
ON DUPLICATE KEY UPDATE name='jeeva',price='$100';
UPDATE table SET name='jeeva',price='$100' WHERE id=1;
For Example:
Consider following query if key id is '1' existing table it will perform update query like second query. otherwise it will insert as new record.
INSERT INTO product (id,name,price) VALUES (1,'jeeva','$100')
ON DUPLICATE KEY UPDATE name='jeeva',price='$100';
UPDATE table SET name='jeeva',price='$100' WHERE id=1;