PHP SQL Update array

后端 未结 5 1569
南方客
南方客 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:10

    If you want to update multiple rows (in single query) using the INSERT syntax, you can do this:

    REPLACE table(id,status) VALUES(1,1),(2,2),(3,3)
    

    Notice that id must be Primary Key or Unique, otherwise the REPLACE will insert a new row. Notice also that REPLACE isn't SQL standard, and works only in MySQL.

提交回复
热议问题