©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The IFNULL Function - If NULL query in SQL statements

IFNULLSyntax:IFNULL(Expression, Value)
Return value:Depending on the data types used
Function type:NULL function
Function Description

The IFNULL() function returns "Value" if the value of "Expression" is NULL.

If "Expression" is not NULL, IFNULL() returns the "Expression".

The return type corresponds to the data type of "Expression" or "Value", depending on the result of the function.

SQL Examples for the IFNULL function


SELECT ifnull(null'Value');
SELECT ifnull('ok''Value');
SELECT ifnull(nullif('ok''notok'), 'value');
SELECT ifnull(nullif('ok''ok'), 'value');
SELECT ifnull(nullif('ok''ok'), null);

ifnull(null, 'Value')
varchar(5) BINARY
ifnull('ok', 'Value')
varchar(5) BINARY
ifnull(nullif('ok', 'notok'), 'value')
varchar(5) BINARY
ifnull(nullif('ok', 'ok'), 'value')
varchar(5) BINARY
ifnull(nullif('ok', 'ok'), null)
varchar(2) BINARY
The examples were created with the MyWAY SQL manager: Download

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

With the IFNULL() function in MySQL and MariaDB databases, NULL values ​​in queries or expressions are processed by providing a default or alternate value as a replacement value when the value of a column or expression evaluates to NULL. The function can be used to avoid NULL values ​​interfering with calculations, comparisons, or the display of results.

Further MySQL und MariaDB SQL NULL functions

More about COALESCE Function

More about ISNULL Function

NULLIFNULLIF(Expression 1, Expression 2)
More about NULLIF Function

NVLNVL(Expression, Value)
More about NVL Function

NVL2NVL2(Expression, Value1, Value2)
More about NVL2 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 IFNULL SQL function: mysql.com and mariadb.com and w3schools.com
Updated: 2023-09-24ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer