Yes, that’s possible – you can use INSERT … ON DUPLICATE KEY UPDATE.
Using your example:
INSERT INTO table (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);
More Related Contents:
- MySQL, update multiple tables with one query
- UPDATE multiple rows with different values in one query in MySQL
- mysql update column with value from another table
- update multiple rows using limit in mysql?
- MySQL/SQL: Update with correlated subquery from the updated table itself
- What are differences between INSERT and UPDATE in MySQL?
- MySql – Way to update portion of a string?
- MySQL UPDATE syntax with multiple tables using WHERE clause
- The best way to remove value from SET field?
- Update MySQL with if condition
- Update multiple rows with multiple ‘where’ clauses for each individual row
- MySQL update statement to store ranking positions
- get first occurrence of last changed value of a column [closed]
- MySQL – Rows to Columns
- ROW_NUMBER() in MySQL
- multiple query same table but in different columns mysql
- How can I temporarily disable a foreign key constraint in MySQL?
- How to do a batch insert in MySQL
- Return default result for IN value regardless
- How can I search (case-insensitive) in a column using LIKE wildcard?
- sql joins as venn diagram
- How can I join multiple SQL tables using the IDs?
- MySQL, better to insert NULL or empty string?
- Why do results from a SQL query not come back in the order I expect?
- MySQL combine two columns and add into a new column
- How to set a MySQL row to READ-ONLY?
- Getting first day of the week in MySql using Week No
- SQL date format convert? [dd.mm.yy to YYYY-MM-DD]
- What happens when I exhaust a bigint generated key? How to handle it?
- is there a length limit to group_concat or another reason why it would not work on a text field