MariaDB NVL SQL Function - If NULL query in Oracle mode |
|
| NVL | Syntax: | NVL(Expression, Value) | Return value: | Depending on the data types used | Synonyms: | IFNULL | Function type: | NULL function | |
| | The NVL() function returns "Value" if the value of "Expression" is NULL.
If "Expression" is not NULL, NVL() returns the "Expression".
The return type is the type of "Expression" or "Value", depending on the result of the function.
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 NVL function |
|
SELECT nvl(null, 'Value');
SELECT nvl('ok', 'Value');
SELECT nvl(nullif('ok', 'notok'), 'value');
SELECT nvl(nullif('ok', 'ok'), 'value');
SELECT nvl(nullif('ok', 'ok'), null);
|
|
nvl(null, 'Value') |
varchar(5) BINARY |
Value |
|
|
nvl('ok', 'Value') |
varchar(5) BINARY |
ok |
|
|
nvl(nullif('ok', 'notok'), 'value') |
varchar(5) BINARY |
ok |
|
|
nvl(nullif('ok', 'ok'), 'value') |
varchar(5) BINARY |
value |
|
|
nvl(nullif('ok', 'ok'), null) |
varchar(2) BINARY |
NULL |
|
|
| The examples were created with the MyWAY SQL manager: | How to use the NVL() function in MariaDB databases | The NVL() function in MariaDB can handle NULL values by having the function provide a default or alternate value when a column or expression NULL yields and is useful for calculations, comparisons, or displaying results that use NULL values. The function is equivalent to the IFNULL() function and was introduced in MariaDB for Oracle compatibility. | | Further MySQL und MariaDB SQL NULL functions | |
| | More information about the NVL SQL function: |
|
|
|
|