我有一个mysql UPDATE查询:
$updateExpries = "UPDATE table SET
field = '$value'
WHERE oneField != '$anotherValue'";
我如何才能获得刚刚更新过的所有项目,并为每个项目单独更新另一个字段?
答案 0 :(得分:1)
您可以更新表格中的多个字段:
UPDATE table
SET
field = 'value',
field2 = 'another value',
field3 = 'third value'
WHERE oneField != 'term'
答案 1 :(得分:0)
if($res = $sqli->query($updateExpries)) {
while ($row = $res->fetch_assoc()) {
$fieldFromQuery = $row["someField"];
$newQuery = "UPDATE table SET newfield = '$fieldFromQuery' WHERE someotherField != '$Valuewhaterver'";
...
}
} else handle error;
如果您不使用sqli
,或类似的东西