MySQL - Explain CASE Expression in MySQL with syntax

Explain CASE Expression in MySQL with syntax.

CASE statement is a conditional expression. It is used to execute specific statements when some search condition evaluates to TRUE.

Syntax 1:
CASE WHEN condition THEN result
WHEN condition THEN result
WHEN condition THEN result
...
ELSE result
END

Syntax 2:
When no value is matched, the statements are executed.
CASE value WHEN target_value THEN result
WHEN target_value THEN result
WHEN target_value THEN result
...
ELSE result
END

Example:
CASE sample
WHEN NULL THEN SELECT 'This is test';
ELSE SELECT 'Not test';
END CASE;
MySQL - TIMESTAMP data type in MySQL
TIMESTAMP data type in MySQL - A TIMESTAMP data type allows you to record a date and time like DATETIME data.....
MySQL - What is a User Account and Predefined User Accounts in MySQL?
What is a User Account and Predefined User Accounts in MySQL? - A user account in MySQL is assigned a username and password to access MySQL databases......
MySQL - Explain how to add a new user account in MySQL
Explain how to add a new user account in MySQL - New users in MySQL can be added using the CREATE USER.....
Post your comment