我的专栏(jwqt5_rsform_submission_values)具有2个值value1和value2
我想将value1更改为firstvalue,将value2更改为secondvalue
我的php代码:
$user = JFactory::getUser();
$db = JFactory::getDbo();
$db->setQuery("UPDATE `jwqt5_rsform_submission_values` SET `FieldValue` = 'firstvalue' WHERE `FieldValue` = 'value1'");
return $db->loadResult();
$user = JFactory::getUser();
$db1 = JFactory::getDbo();
$db1->setQuery("UPDATE `jwqt5_rsform_submission_values` SET `FieldValue` = 'secondvalue' WHERE `FieldValue` = 'value2'");
return $db1->loadResult();
最佳答案
您可以像这样组合查询:
UPDATE jwqt5_rsform_submission_values
SET FieldValue = CASE FieldValue
WHEN 'value1' THEN 'firstvalue'
WHEN 'value2' THEN 'secondvalue'
END
WHERE FieldValue IN ('value1', 'value2')
关于php - 更新php中的mysql同一列数据更新1个表中的2个不同,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47364096/