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, 1725🔥, 0💬
Popular Posts:
How To Escape Special Characters in SQL statements in MySQL? There are a number of special character...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...
How to check if two JSON values have overlaps using the JSON_OVERLAPS() function? JSON_OVERLAPS(json...
How To Count Rows with the COUNT(*) Function in SQL Server? If you want to count the number of rows,...
How to print value on console in SQL Server Transact-SQL? How to use the PRINT statements? In Transa...