MCQs>IT & Programming>MySQL>Best way to update multiple rows? Example: Name id Col1 Col2 name1 1 6 1 name2 2 2 3 name3 3 9 5 name4 4 16 8 Update Col1= 1 where id = 1 Update Col1= 2 where id = 2 Update Col2= 3 where id = 3 Update Col1= 10 and col2= 12 where id = 4
MySQL MCQs
Which of the following is the best way to update multiple rows? Example: Name id Col1 Col2 name1 1 6 1 name2 2 2 3 name3 3 9 5 name4 4 16 8 Update Col1= 1 where id = 1 Update Col1= 2 where id = 2 Update Col2= 3 where id = 3 Update Col1= 10 and col2= 12 where id = 4
Answer
Correct Answer: INSERT INTO table_name (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);
Explanation:
Note: This Question is unanswered, help us to find answer for this one