IFNULL
Syntax
IFNULL(expr1,expr2) NVL(expr1,expr2)
Contents
Description
If expr1
is not NULL, IFNULL() returns expr1
; otherwise it returns
expr2
. IFNULL() returns a numeric or string value, depending on the
context in which it is used.
From MariaDB 10.3, NVL() is an alias for IFNULL().
Examples
SELECT IFNULL(1,0); +-------------+ | IFNULL(1,0) | +-------------+ | 1 | +-------------+ SELECT IFNULL(NULL,10); +-----------------+ | IFNULL(NULL,10) | +-----------------+ | 10 | +-----------------+ SELECT IFNULL(1/0,10); +----------------+ | IFNULL(1/0,10) | +----------------+ | 10.0000 | +----------------+ SELECT IFNULL(1/0,'yes'); +-------------------+ | IFNULL(1/0,'yes') | +-------------------+ | yes | +-------------------+
See Also
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.