The CASE statement is a conditional expression that can be used anywhere a value expression is used. It allows for the evaluation of multiple conditions, returning a specified value when a condition is true, or a default value when none of the conditions is true. There are three functions, NULLIF, COALESCE, and IFNULL, that are designed to handle a subset of the CASE functionality.
The following syntax diagrams describe the CASE statement:
As indicated in the syntax diagrams, there are two types of CASE statements: