ID EN
Comparison Functions and Operators

IS NULL

MySQL 8.4

Tests whether a value is NULL.

Syntax

MYSQL
SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL;
0, 0, 1

Examples

Example

To work well with ODBC programs, MySQL supports the following extra features when using IS NULL:

MYSQL
SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL;
0, 0, 1
Example 2

If sql_auto_is_null variable is set to 1, then after a statement that successfully inserts an automatically generated AUTO_INCREMENT value, you can find that value by issuing a statement of the following form:

MYSQL
SELECT * FROM tbl_name WHERE auto_col IS NULL
Example 3

If the statement returns a row, the value returned is the same as if you invoked the LAST_INSERT_ID() function. For details, including the return value after a multiple-row insert, see Section 14.15, “Information Functions”. If no AUTO_INCREMENT value was successfully inserted, the SELECT statement returns no row.

MYSQL
SELECT * FROM tbl_name WHERE date_column IS NULL