> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/nullif.md).

# NULLIF

## Syntax

```bnf
NULLIF(expr1,expr2)
```

## Description

Returns `NULL` if expr1 = expr2 is true, otherwise returns expr1. This is the same as [CASE](/docs/server/reference/sql-functions/control-flow-functions/case-operator.md) `WHEN` expr1 = expr2 `THEN NULL ELSE` expr1 `END`.

## Examples

```sql
SELECT NULLIF(1,1);
+-------------+
| NULLIF(1,1) |
+-------------+
|        NULL |
+-------------+

SELECT NULLIF(1,2);
+-------------+
| NULLIF(1,2) |
+-------------+
|           1 |
+-------------+
```

## See Also

* [NULL values](/docs/server/reference/data-types/null-values.md)
* [IS NULL operator](/docs/server/reference/sql-structure/operators/comparison-operators/is-null.md)
* [IS NOT NULL operator](/docs/server/reference/sql-structure/operators/comparison-operators/is-not-null.md)
* [COALESCE function](/docs/server/reference/sql-structure/operators/comparison-operators/coalesce.md)
* [IFNULL function](/docs/server/reference/sql-functions/control-flow-functions/ifnull.md)
* [CONNECT data types](/docs/server/server-usage/storage-engines/connect/connect-data-types.md#null-handling)

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}
