suppose I have the query:
INSERT INTO TABLE (column1, column2, column3, column4) VALUES
(val11, val21, val31, val41),
(val12, val22, val32, val 42)
....
And then I put in a whole bunch of more values
ON DUPLICATE KEY UPDATE (some update clause)
Is it possible to modify this query so that for some of the rows (assuming they’re duplicate keys), I set it so that column3 gets updated to a value I set while column 4 remains as it is while for some rows, I update column4 to certain values while column3 remains as it is…Ie. is it possible to selectively update different columns within this one single query, leaving the rest as it were without splitting it up to more than one query?
Looks like MySQL supports performing conditional logic in the DUPLCIATE KEY UPDATE clause
http://thewebfellas.com/blog/2010/1/18/conditional-duplicate-key-updates-with-mysql
The IF allows you to supply “if-else” parameters. So I think you could do something like this