©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
This website works better with Javascript
The MyWAY SQL Manager can be downloaded here for free: as PHP installation file as GZIP file as ZIP archive
If the download from this page does not work, you can also download the program here (Virus checked at heise.de).
By downloading you accept the General Terms and Conditions
The program MyWAY SQL-Manager only works with Javascript
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The COALESCE SQL Function in MySQL and MariaDB - Non-NULL value from list

COALESCESyntax:COALESCE(%, %)
Return value:Depending on the data types used
Function type:Comparison function, NULL function
Function Description

The COALESCE() function returns the first value from a list that is not NULL.

If no non-NULL value is found, COALESCE() returns NULL.

SQL Examples for the COALESCE function

 1
 2
 3
 4
 5

select COALESCE(null'Test'null'Test2');
select COALESCE(null, 45, null, 13);
select COALESCE(nullnullnullnull);

COALESCE(null, 'Test', null, 'Test2')
varchar(5) BINARY
Test
COALESCE(null, 45, null, 13)
int(2)
45
COALESCE(null, null, null, null)
NULL
The examples were created with the MyWAY SQL manager: Download

How to use the COALESCE() function in MySQL and MariaDB databases

The MySQL and MariaDB COALESCE() function returns the first non-NULL expression from a list of expressions, where function evaluates the expressions in order from left to right and returns the first non-NULL value. If all expressions are NULL, the function returns NULL. The function can also be used with more than two expressions, if you want to process null values ​​and provide default values ​​or alternative expressions. The function allows replacing NULL values ​​with alternative or desired values ​​in results of SQL queries or expressions. The COALESCE() function in MySQL and MariaDB provides a convenient way to handle NULL values.
CHARACTER_LENGTHCHARSETCHRCOALESCECOERCIBILITYCOLLATIONCOMPRESS

Further MySQL und MariaDB SQL Comparison functions

DECODE_ORACLEDECODE_ORACLE()
More about DECODE_ORACLE Function

GREATESTGREATEST(%, %)
More about GREATEST Function

INTERVALINTERVAL(%, %)
More about INTERVAL Function

IFIF(Expression, Value1, Value2)
More about IF Function

LEASTLEAST(%, %)
More about LEAST Function

STRCMPSTRCMP(String 1, String 2)
More about STRCMP Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the COALESCE SQL function: mysql.com and mariadb.com and w3schools.com
Updated: 2025-11-04ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedin©2020-2025 Heino Cunze-Fischer