I want to update and insert to (in 1 query) my table. I've 1 new row and 2 old records. I use this query (topic):
INSERT INTO table (id, title, url) VALUES (1, "test", "http://"), (2, [it is an old record. I don't want to change its title], "https://"), (3, "helloworld", "mms://") ON DUPLICATE KEY UPDATE title = VALUES(title), url = VALUES(url)
I don't want to change the second record (id = 2
) title
column, but if I put NULL
, DEFAULT
or title
after comma, title
will change to NULL
(also if i put nothing after comma, an error will occur)
What can I do? should I use 2 or more queries?
Thank you.