All pages
Powered by GitBook
1 of 1

Loading...

NULLIF

Compare two expressions and return NULL if they are equal. If the expressions differ, the function returns the first expression.

Syntax

NULLIF(expr1,expr2)

Description

Returns NULL if expr1 = expr2 is true, otherwise returns expr1. This is the same as WHEN expr1 = expr2 THEN NULL ELSE expr1 END.

Examples

See Also

This page is licensed: GPLv2, originally from

IFNULL function
  • CONNECT data types

  • CASE
    NULL values
    IS NULL operator
    IS NOT NULL operator
    COALESCE function
    fill_help_tables.sql
    SELECT NULLIF(1,1);
    +-------------+
    | NULLIF(1,1) |
    +-------------+
    |        NULL |
    +-------------+
    
    SELECT NULLIF(1,2);
    +-------------+
    | NULLIF(1,2) |
    +-------------+
    |           1 |
    +-------------+