I google it but I could not find what I need exactly.
I supposed to execute multiple update query in a single statement using PREPARE
, EXECUTE
in MySQL
.
Sample query:
update tableName set column2='a', column3='b' where column1=1;
update tableName set column2='c', column3='d' where column1=2;
update tableName set column2='f', column3='g' where column1=3;
SET @Query=myUpdateQuery;
PREPARE stmt FROM @Query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
I try using above query but I encountered with an error
Error Code: 1064 You have an error in your SQL syntax;
I am struggling to overcome this error.
Please let me me know the way to accomplish my need. Thanks in advance.