Home >Database >Mysql Tutorial >Which MySQL function is used to find the first non-NULL value from a list of values?
We can use the MySQL COALESCE() function to get the first non-NULL value from the list of values as output. In other words, the function will check all values until it finds a non-null value. It can take one or more parameters. It has the following syntax:
COALESCE(value1, value2, …, valueN)
Here is an example to demonstrate it -
mysql> Select COALESCE(NULL, NULL, NULL, 'Ram', 'Aarav', NULL); +--------------------------------------------------+ | COALESCE(NULL, NULL, NULL, 'Ram', 'Aarav', NULL) | +--------------------------------------------------+ | Ram | +--------------------------------------------------+ 1 row in set (0.00 sec)
The above is the detailed content of Which MySQL function is used to find the first non-NULL value from a list of values?. For more information, please follow other related articles on the PHP Chinese website!