我知道PHP之类的语言具有切换用例控制结构,该结构支持在单个case语句中进行多种验证,例如,
Switch $x { case 1,2,3: $a = 0; break; case 5,6: $a = 1; break; }
同样可以在MYSQL中完成吗?我在下面尝试过,但这真的没有用:(
CASE vc_shape WHEN ('02' OR '51') THEN SET dc_square_1 = dc_square_1 + dc_row_total; WHEN ('06' OR '30' OR 83) THEN SET dc_square_2 = dc_square_2 + dc_row_total; ..... ..... ELSE BEGIN END; END CASE;
有什么想法可以实现吗?
对CASE语句使用其他格式:
CASE
CASE WHEN vc_shape IN ('02', '51') THEN SET dc_square_1 = dc_square_1 + dc_row_total; WHEN vc_shape IN ('06', '30', '83') THEN SET dc_square_2 = dc_square_2 + dc_row_total; ..... ..... ELSE BEGIN END; END CASE;