在下面的查询中,前两个案例正在解决原因
UPDATE `FundCategory` SET `fundCategoryValue` =
CASE
WHEN `fundCategoryId` = '7' THEN fundCategoryValue + 700
WHEN `fundCategoryId` = '5' THEN fundCategoryValue - 700
WHEN `fundCategoryId` = '5' THEN fundCategoryValue + 700
WHEN `fundCategoryId` = '7' THEN fundCategoryValue - 700
ELSE `fundCategoryValue`
END
WHERE `fundCategoryId` IN('7','5','5','7')
答案 0 :(得分:2)
条件在前两个条件之后重复......并且case语句在找到工作条件时停止...所以最后两个不能工作。
答案 1 :(得分:0)
你有两次相同的情况:
WHEN `fundCategoryId` = '7' THEN fundCategoryValue + 700
WHEN `fundCategoryId` = '5' THEN fundCategoryValue - 700
WHEN `fundCategoryId` = '5' THEN fundCategoryValue + 700
WHEN `fundCategoryId` = '7' THEN fundCategoryValue - 700