I know languages like PHP has switch case control structure that supports multiple validations in a single case statement like,
Switch $x {
case 1,2,3:
$a = 0;
break;
case 5,6:
$a = 1;
break;
}
Similarly can this be done in MYSQL? I tried below, which really didn't work though :(
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;
Any ideas how can I achieve this?
Use the other format for CASE
statements:
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With