Updating multiple rows with different values

前端 未结 3 2065
忘了有多久
忘了有多久 2020-12-31 19:07

I got this table in my MySQL database, \'users\'. It has the fields \'id\' and \'value\'.

Now, I want to update lots of rows in this table with a single

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-31 19:11

    Assuming id is unique or primary...

    insert into users 
      (id,value) 
    VALUES 
      (1,53),(2,65),(3,47),(4,53),(5,47)
    on duplicate key update
    value=VALUES(value)
    

提交回复
热议问题