PHP SQL Update array

后端 未结 5 1599
南方客
南方客 2021-01-28 02:49

I originally was satisfied with the following in order to update row 1 and row 2 to the same value (status=1)

if ($_POST){
    $sql =\"UPDATE table SET  status =         


        
5条回答
  •  忘了有多久
    2021-01-28 03:12

    If yow want the status to be equal to the id, do this (single query):

    UPDATE table SET status=id WHERE id IN (1,2,3);
    

    Of course you can use some math, like:

    UPDATE table SET status=(id+1)*2 WHERE id IN (1,2,3);
    

提交回复
热议问题