MySQL COALESCE() Function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The MySQL COALESCE() function returns the first non-null value in a list of expressions. COALESCE function in MySQLThe COALESCE function in MySQL is used to get the first non-null value from a list of expressions. If all the values in the list are evaluated to NULL, then the COALESCE() function returns NULL. The COALESCE() function accepts one parameter, which is the list, which can contain various values. SyntaxThe MySQL COALESCE function syntax is: COALESCE(value_1, value_2, ...., value_n) Parameters: value_1: It is used to specify the first value in the list. COALESCE( ) function is supported in following versions of MySQL MySQL 5.7, MySQL 5.6 ,MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23MySQL COALESCE() Function ExamplesLet's look at some examples of the COALESCE() function in MySQL and understand how to use COALESCE function. Using COALESCE() function on a list exampleIn this example, we will use the COALESCE function on a list of values where the first value is NULL. Query: SELECT COALESCE(NULL, 'A', 'B', NULL); Output: A Example 2In this example, we will use the COALESCE function on a list of values where the first value is not NULL Query SELECT COALESCE('A', NULL, 'B', NULL); Output: A Important Points About MySQL COALESCE() FunctionMySQL COALESCE() function is used to return the first non-NULL value from a list of expressions.If all the expressions evaluate to NULL, the COALESCE() function will return NULL.COALESCE() can be used to substitute NULL values in table columns with a default value or an expression.COALESCE() is more flexible than IFNULL() as it can handle any number of arguments, while IFNULL() only takes two arguments. Comment More infoAdvertise with us Next Article MySQL CASE() Function S Shubrodeep Banerjee Follow Improve Article Tags : SQL mysql SQLmysql Similar Reads MySQL CASE() Function MySQL CASE function is a conditional statement that returns a value when the first condition is met. Once a condition is met, the CASE function does not check for other conditions. If no condition is met it returns the output in ELSE part. CASE Function in MySQLThe CASE Function in MySQL allows usin 4 min read MySQL | COMPRESS( ) Function The MySQL COMPRESS() function is used for the compression of a string. The value returned by the COMPRESS() function is a binary string. The COMPRESS() function stores non-empty strings as a four-byte length of the uncompressed string, which is then followed by the compressed string. If the string e 1 min read SQL Server COALESCE() Function The COALESCE() function in SQL Server is a powerful tool designed to handle NULL values effectively. It evaluates a list of expressions in a specified order and returns the first non-null value encountered.In this article, We will learn about the SQL Server COALESCE() by understanding various exampl 4 min read MySQL | CONV( ) Function The MySQL CONV() function is used for converting a number from one numeric base system to another. The value returned by the CONV() function is in the form of a string value. It accepts three parameters which are the value to be converted, the current numeric base system and the numeric base system 2 min read MySQL | CONVERT( ) Function The MySQL CONVERT() function is used for converting a value from one datatype to a different datatype. The MySQL CONVERT() function is also used for converting a value from one character set to another character set. It accepts two parameters which are the input value and the type to be converted in 2 min read CONCAT() function in MySQL CONCAT() function in MySQL is used to concatenating the given arguments. It may have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. If a numeric argument is given then it is 2 min read Like