我的列(jwqt5_rsform_submission_values)有2个值value1和value2 我希望changw 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();
答案 0 :(得分:0)
您可以合并这样的查询:
UPDATE jwqt5_rsform_submission_values
SET FieldValue = CASE FieldValue
WHEN 'value1' THEN 'firstvalue'
WHEN 'value2' THEN 'secondvalue'
END
WHERE FieldValue IN ('value1', 'value2')