简体   繁体   English

在PHP中批量更新

[英]Batch update in php

I have a mysql table with multiple fields: 我有一个包含多个字段的mysql表:

 SNo id status 

Now the status has changed and i need to update it when the value of Sno is 1 from my php script. 现在状态已经改变,我需要在我的php脚本中Sno的值为1时更新它。 I do not want to do it individually as this may be time consuming. 我不想单独进行,因为这可能很耗时。 Is there any way to update the values of status when I have the value of Sno which it corresponds to other than deleting these columns and doing an insert again. 当我有Sno的值时,有没有办法更新状态值,它与删除这些列并再次执行插入相对应。

The value of new status is not a constant. 新状态的值不是常数。 Lets assume that there are 4 entries with sno 1 and the status field is originally all false. 让我们假设有4个条目与sno 1,状态字段最初都是假的。 Now lets say I want to update it and have a string true,true,false,false. 现在让我说我想更新它并使字符串为true,true,false,false。 I want the staus to be updated to true,true,flase,false exactly in the order that they appear in the table. 我希望staus按照它们在表中出现的顺序更新为true,true,flase,false。

不完全确定你的意思,但我认为你在寻找:

UPDATE `table` SET `status` = 'new status' WHERE `SNo` = '1'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM