What is the resemblance of COALESCE() function with IF-THEN-ELSE statement?

MySQLMySQLi Database

As we know that COALESCE() function returns first non-NULL value from the list of values. The following IF-THEN-ELSE statement is equivalent to COALESCE() function.

IF value1 is not NULL THEN
output = value1;
ELSIF value2 is not NULL THEN
output = value2;
ELSIF value3 is not NULL THEN
output = value3;
.
.
.
ELSIF valueN is not NULL THEN
output = valueN;
ELSE
output = NULL;
END IF;
raja
Published on 20-Feb-2018 13:34:18
Advertisements