In mysql, you can use the SELECT statement with the IS NULL keyword to query for null values. The IS NULL keyword is used to determine whether the field value is a null value. If the field value is a null value, it is displayed in In the result, the syntax is "SELECT * FROM table name WHERE field name IS NULL;".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
MySQL provides the IS NULL keyword to determine whether the value of a field is NULL. The null value is different from 0, which is also different from the empty string.
If the value of the field is null, the query conditions are met and the record will be queried. If the value of the field is not null, the query condition is not met.
The basic syntax format for using IS NULL is as follows:
IS [NOT] NULL
Among them, "NOT" is an optional parameter, indicating that the condition is met when the field value is not a null value.
Example 1
The following uses the IS NULL keyword to query the records whose login_date field is NULL in the tb_students_info table.
Note: IS NULL is a whole, IS cannot be replaced with "=". If you replace IS with "=", no results will be retrieved, and the database system will display a prompt such as "Empty set (0.00 sec)". Similarly, IS NOT in IS NOT NULL cannot be replaced with "!=" or "".
IS NOT NULL means querying records whose field value is not empty.
Example 2
The following uses the IS NOT NULL keyword to query the records where the login_date field in the tb_students_info table is not empty.
Recommended learning:mysql video tutorial
The above is the detailed content of How to query null value in mysql. For more information, please follow other related articles on the PHP Chinese website!