Get in touch
or send us a question?
CONTACT

Multiple Updates in MySQL

For example I have the following test table

id  Col1  Col2
1    6     1
2    2     3
3    9     5
4    16    8

Using below SQL for Insert/Update

INSERT INTO test (id,Col1,Col2) VALUES (1,1,1),(2,2,3),(3,9,3),(4,10,12)
ON DUPLICATE KEY UPDATE Col1=VALUES(Col1),Col2=VALUES(Col2);