Thursday, May 15, 2014

MySQL COALESCE() function

MySQL COALESCE() function returns the first non-NULL value of a list, or NULL if there are no non-NULL values.
MySQL Version : 5.6



Syntax

COALESCE(value1,value2,value3,...)
The above syntax is equivalent to the following IF-THEN-ELSE statement
  IF value1 is not NULL THEN
     result = value1;
  ELSIF value2 is not NULL THEN
     result = value2;
  ELSIF value3 is not NULL THEN
     result = value3;
  ELSE
     result = NULL;
  END IF; 
- See more at: http://www.w3resource.com/mysql/comparision-functions-and-operators/coalesce-function.php#sthash.mgOL7uGR.dpuf

0 comments:

Post a Comment