Update multiple rows with one query

前端 未结 3 2027
孤独总比滥情好
孤独总比滥情好 2021-01-06 09:18

How can I update hundreds of rows at once?

Like: UPDATE table SET a = ? WHERE b = ? AND c = 1

but for many rows. The ? parameters a

3条回答
  •  无人及你
    2021-01-06 10:07

    Use the CASE method as described in the link you provided, but build the query dynamically with the values you want.

    Likely, this will be built with a for loop similar to how you're already doing it, but you will end up with a single query rather than querying your database every iteration.

提交回复
热议问题