How do I combine two UPDATE statements in one MySQL query?

后端 未结 6 1348
野的像风
野的像风 2020-12-18 11:44

Greetings,

How would one go about performing two UPDATE statements in one query, for example:

UPDATE albums SET isFeatured = \'0\' WHERE isFeatured          


        
6条回答
  •  误落风尘
    2020-12-18 12:01

    I don't think you can, or at least not in a neat or practical way.

    If you're wanting to do one call from php/whatever then you can seperate them with semicolons thus:

    UPDATE albums SET isFeatured = '0' WHERE isFeatured = '1';UPDATE albums SET isFeatured = '1' WHERE id = '$id';
    

提交回复
热议问题