当前位置:Gxlcms > 数据库问题 > MySQL批量UPDATE多行记录

MySQL批量UPDATE多行记录

时间:2021-07-01 10:21:17 帮助过:23人阅读

UPDATE categories
    SET display_order = CASE id
        WHEN 1 THEN 3
        WHEN 2 THEN 4
        WHEN 3 THEN 5
    END,
    title = CASE id
        WHEN 1 THEN ‘New Title 1‘
        WHEN 2 THEN ‘New Title 2‘
        WHEN 3 THEN ‘New Title 3‘
    END
WHERE id IN (1,2,3)

MySQL批量UPDATE多行记录

标签:

人气教程排行