nullif

description

Syntax

nullif(expr1, expr2)

If the two parameters are equal, null is returned. Otherwise, the value of the first parameter is returned. It has the same effect as the following case when

  1. CASE
  2. WHEN expr1 = expr2 THEN NULL
  3. ELSE expr1
  4. END

example

  1. mysql> select nullif(1,1);
  2. +--------------+
  3. | nullif(1, 1) |
  4. +--------------+
  5. | NULL |
  6. +--------------+
  7. mysql> select nullif(1,0);
  8. +--------------+
  9. | nullif(1, 0) |
  10. +--------------+
  11. | 1 |
  12. +--------------+

keywords

NULLIF