Mysql 批量更新数据

in Default with 0 comment

mysql 更新单条数据

update set table1 name = xxx where id =1

mysql 更新多条数据

UPDATE table1 
    SET name = CASE id
        WHEN 1 THEN xxx1
        WHEN 2 THEN xxx2
        WHEN 3 THEN xxx3
    END
WHERE id IN (1,2,3)

更新 table1 表的 name 字段,当 id 等于 1 时 ,更新 name = xxx1

Responses