©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 functionMariaDB

MariaDB NVL2 SQL Function - If NULL selection - Oracle

NVL2Syntax:NVL2(Expression, Value1, Value2)
Return value:Depending on the data types used
Function type:NULL function
Function Description

The NVL2() function returns "Value2" if the value of "Expression" is NULL.

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


The feature was introduced starting with MariaDB Version 10.3 for Oracle compatibility.

In MySQL 8.0 this feature is not present.

SQL Examples for the NVL2 function

 1
 2
 3
 4
 5
 6

SELECT nvl2(null'Value1''Value2');
SELECT nvl2('ok''Value2''Value2');
SELECT nvl2(nullif('ok''notok'), 'value1''Value2');
SELECT nvl2(nullif('ok''ok'), 'value1''Value2');

nvl2(null, 'Value1', 'Value2')
varchar(6) BINARY
Value2
nvl2('ok', 'Value2', 'Value2')
varchar(6) BINARY
Value2
nvl2(nullif('ok', 'notok'), 'value1', 'Value2')
varchar(6) BINARY
value1
nvl2(nullif('ok', 'ok'), 'value1', 'Value2')
varchar(6) BINARY
Value2
The examples were created with the MyWAY SQL manager: Download

How to use the NVL2() function in MariaDB databases

The NVL2() function in MariaDB can handle NULL values ​​by having the function provide different alternative values, depending on whether a table column or expression evaluates to NULL or not, providing flexibility in handling NULL values ​​and allowing SQL queries to be returned adjust based on the nullness of the expression. The first parameter is the expression to evaluate, followed by the value to return if the expression is not NULL and the value to return if the expression is NULL. The function was introduced in MariaDB for Oracle compatibility.
NOWNULLIFNVLNVL2OCTOCTET_LENGTHOLD_PASSWORD

Further MySQL und MariaDB SQL NULL functions

COALESCECOALESCE(%, %)
More about COALESCE Function

IFNULLIFNULL(Expression, Value)
More about IFNULL Function

ISNULLISNULL(Expression)
More about ISNULL Function

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

NVLNVL(Expression, Value)
More about NVL 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 NVL2 SQL function: mariadb.com
Updated: 2025-11-04ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedin©2020-2025 Heino Cunze-Fischer