In focus

How To Use NULL Values In MySQL

In this article we will learn about null values in MySQL.

Akhil Kumar May 09, 2016

In MySQL, NULL represents an unknown value. A NULL is never equal to any, even another NULL. Operator returns true if column value is NULL.

Step 1 - First we will create the database.

mysql1

mysql2

Here I created the database with name mindcracker.

Step 2 - Now we will create the table.

mysql3

So our table student is created.

Step 3 - Now we will insert values in our table.

mysql4

mysql5

So here is the created table.

Step 4 - Now we write the following MySql query to fetch the student where name is NULL.

mysql6

Summary

Here we see that to fetch the student with NULL value we have not write the select query like this

  1. select * from student where name=NULL;  
Because we know that NULL value can't be equal to a value. So to fetch the student with NULL value we have to use is keyword with where clause in select statement. 

database mysql null

COMMENT USING