Collections:
COALESCE() - Finding First Non-NULL Value
How to find the first non-NULL value from a list using the COALESCE() function?
✍: FYIcenter.com
COALESCE(val1, val2, ...) is a MySQL built-in function that
returns the first non-NULL value from a given list of values.
For example:
SELECT COALESCE(NULL, 'FYI', NULL, 3.14); -- +-----------------------------------+ -- | COALESCE(NULL, 'FYI', NULL, 3.14) | -- +-----------------------------------+ -- | FYI | -- +-----------------------------------+
Reference information of the COALESCE() function:
COALESCE(val1, val2, ...): val Returns the first non-NULL value from a given list of values. Arguments, return value and availability: val1, val2, ...: One or more values to be examined. val: Return value. The first non-NULL value. Available since MySQL 4.0.
⇒ CONVERT() - Character Set Conversion
⇐ CAST() - Casting Expression to Value
2026-03-22, 1352🔥, 0💬
Popular Posts:
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPA...
How To Drop an Index in Oracle? If you don't need an existing index any more, you should delete it w...
How To Divide Query Output into Multiple Groups with the GROUP BY Clause in SQL Server? Sometimes, y...
Where to find answers to frequently asked questions on Managing Security, Login and User in SQL Serv...
How To Convert Numeric Values to Integers in SQL Server Transact-SQL? Sometimes you need to round a ...