NULLIF (exp1, exp2)

NULLIF returns exp1 if the two expressions are not equivalent. If the expressions are equivalent, NULLIF returns a NULL value.

Since the second row contains the NULL value, 'foo' is substituted in its place.

SELECT IFNULL(col1, 'foo') FROM Demo

This results in three rows fetched from one column:




3 rows fetched from 1 column.

The first row contains ‘abc,’ which matches the second argument of the following NULLIF call.

SELECT NULLIF(col1, 'abc') FROM Demo

A NULL is returned in its place:




Thursday, 18 April 2019 Posted in Logical Functions