Bulk update mysql with where statement

后端 未结 3 1792
南笙
南笙 2020-12-04 23:25

How to update mysql data in bulk ? How to define something like this :

UPDATE `table` 
WHERE `column1` = somevalues
SET  `column2` = othervalues
3条回答
  •  被撕碎了的回忆
    2020-12-05 00:22

    If you have data in array format then try this

    and your query is like "UPDATE table WHERE column1 = ? SET column2 = ?"

    then set it like below

    foreach($data as $key => $value) {
        $query->bind_param('ss', $key, $value);
        $query->execute();
    }
    

    hope it'll work.

    Reference from this.

提交回复
热议问题