MySQL

MySQL IS NULL

In this tutorial, we are going to see how to check if a column is null, to achieve this we can use the clause IS NULL.
 

Syntax

The syntax of the condition IS NULL in MySQL is as follows:

expression IS NULL

Note:

  • If ‘expression’ is NULL, the condition evaluates to TRUE.
  • If ‘expression’ is not NULL, the condition is evaluated to FALSE.
 
Let’s take a few examples of how to use the clause IS NULL to see how it works. For this we will use the “Clients” table.
 

 

Example 1 – With SELECT statement

This example will display all records in the “Clients” table where the column “Address” contains NULL.

SELECT *
FROM Clients
WHERE Address IS NULL;


 

 

Example 2 – With UPDATE statement

This example will update the records in the “Clients” table where the “Address” column contains NULL.

UPDATE Clients
SET Address = '188 Clay Street Indiana'
WHERE Address IS NULL;

 

Example 3 – With DELETE statement

This example deletes the records from the “Clients” table where the “Address” column contains NULL.

DELETE FROM Clients
WHERE Address IS NULL;
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *