IFNULL(expr1,expr2)
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.
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 | +-------------------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/ifnull/