Monday, 27 April 2015

COALESCE() and ISNULL() Functions in mysql

COALESCE() and ISNULL() Functions

The COALESCE() function returns the first value in the list of arguments that is not NULL. If all values are NULL, then NULL is returned.

SELECT COALESCE(NULL, 2, NULL, 3); ans is 2

It is used to get the 1st value from the list which is not null.


ISNULL ( ) returns a value of 1 if the expression evaluates to NULL; 
otherwise, the function returns a value of 0.

It is used to check whether the value is null or not.

No comments:

Post a Comment