I am trying to make some bulk insert in my table but it should cater for duplicate values. If there are duplicate then it should update the rows instead of updating it.
My table is: user(id, name, url) where id is PK
I tried this:
INSERT INTO `user` (`id`, `name`, `url`)
VALUES
('7656', 'Tom', 'http://user.com/7656'),
('1234', 'Jean', 'http://user.com/1234'),
('8596', 'Pierre', 'http://user.com/8596'),
('2035', 'Somon', 'http://user.com/2035'),
('3685', 'Lola', 'http://user.com/3685')
ON DUPLICATE KEY UPDATE name=VALUES(name), url=VALUES(url)
Assume that all the 5 record that i am trying to insert already exist in my table with just the url to update, how should i do it?
Is it possible to update rows with bulk insert like this?