Is it possible to mass insert/update + increment?

Suppose you have a table foo(name, count);.
I often need to increase the counter count at a different name.
But in order not zombirovanii a bunch of mysql queries continuously, I'm on the backend pre-collect a scope of records to insert/update:
[
 'name1' => 235,
 'name2' => 1,
 'name4' => 3,
// ...
]


Question: is it possible in one query to insert the name of the array if they do not exist, and if exist add the count to the specified value (235, 1, 3, ... to each his own)?
March 25th 20 at 13:19
1 answer
March 25th 20 at 13:21
Solution
Each entry in your X `on duplicate key set count = count + X`. - lynn40 commented on March 25th 20 at 13:24
on duplicate key set count = count + values(X)
https://dev.mysql.com/doc/refman/8.0/en/insert-on-... - terry commented on March 25th 20 at 13:27

Find more questions by tags SQLMySQL