All pages
Powered by GitBook
1 of 1

Loading...

IFNULL

Replace NULL values with a fallback. This function returns the first argument if it's not NULL; otherwise, it returns the specified replacement value.

Syntax

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.

NVL() is an alias for IFNULL().

Examples

See Also

This page is licensed: GPLv2, originally from

IFNULL(expr1,expr2)
NVL(expr1,expr2)
NULLIF function
  • CONNECT data types

  • NULL values
    IS NULL operator
    IS NOT NULL operator
    COALESCE function
    fill_help_tables.sql
    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               |
    +-------------------+