©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
Synonyms:NVL
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

 1
 2
 3
 4
 5
 6
 7

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
Value
ifnull('ok', 'Value')
varchar(5) BINARY
ok
ifnull(nullif('ok', 'notok'), 'value')
varchar(5) BINARY
ok
ifnull(nullif('ok', 'ok'), 'value')
varchar(5) BINARY
value
ifnull(nullif('ok', 'ok'), null)
varchar(2) BINARY
NULL
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.
HEXHOURIFIFNULLINET6_ATONINET6_NTOAINET_ATON

Further MySQL und MariaDB SQL NULL functions

COALESCECOALESCE(%, %)
More about COALESCE Function

ISNULLISNULL(Expression)
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