SQLite IS NULL

First of all, let us know about the word NULL, what does it mean? NULL is nothing but the value or information that is unknown. This NULL value is filled inside the table when no value is given to the particular row or column. The NULL value is always not equal to ZERO.

For example, to understand it in a better way, let us consider a products table and products in the database may have manufacture date and some do not in the same way sometimes there will be no product ID too, these are called NULL values. We use the SQLite IS NULL operator in the WHERE clause.

NULL is the word that is used to represent the missing value.

Syntax

select column1, column2, columnN

from Table Name

Where columname IS NULL;

Now let us try to create the Company table

Syntax

Following is the basic syntax of using NULL while creating a table.

CREATE TABLE Company (
ID INTEGER ,
Name TEXT ,
Age INTEGER ,
Address TEXT,
Salary INTEGER,
PRIMARY KEY("ID")
);

In the above syntax, we are using the create statement to create a table and if we use NOT NULL beside the data type of the column then it does not accept the NULL values. However, I am not using NOT NULL because we need some NULL value rows in order to understand the topic.

Now insert the data into the table

Query:

Insert into company(ID, Name, Age, Address, Salary)
values(1,'Jones', 30, 'Dallas',40000),
(2, 'Mark',NULL ,'New York', 50000),
(3, 'Jessy', 35, 'Verginia', NuLL ),
(4,NuLL,NULL,'Missippi', 60000),
(5,'Rosey',NuLL,NuLL,45000);

We have filled the empty rows with the NULL values and now the table looks like this:

Output:

company table

The values with the NULL values are the rows that do not contain any data in them.

The NULL values affect the total result because when we compare the NULL value with the other value in the table it returns the null value only and then that is not considered in the final results.

SQLite IS NULL

SQLite is a server-less database engine and it is written in c programming language. It is developed by D. Richard Hipp in the year 2000. The main moto for developing the SQLite is to escape from using the complex database engines like MYSQL.etc. It has become one of the most popular database engines as we use it in Television, Mobile Phones, web browsers, and many more. It is written simply so that it can be embedded into other applications.

In this article we will be learning about the SQLite IS NULL operator and by the end of this article, you will get a basic understanding of how the SQLite IS NULL operator works exactly. By the way, we will also be seeing the SQLite IS NOT NULL operator along with the SUM function in the SQLite.

Similar Reads

SQLite IS NULL

First of all, let us know about the word NULL, what does it mean? NULL is nothing but the value or information that is unknown. This NULL value is filled inside the table when no value is given to the particular row or column. The NULL value is always not equal to ZERO....

Examples of SQLITE IS NULL

Now let’s try to bring out some rows with NULL values by using their field names. Now let us display the row where in the salary field there is a null value in the company table....

SQLITE IS NOT NULL

IS NOT NULL means that no missing data and now let us try to fetch the rows that have no null value for the specified field. IS NOT NULL operator fetches the rows that only have the not null values which means simply the rows that have the data for the specified column....

SQLite SUM Function

It is an aggregate function and returns the summation of whatever the expression that you specify. It uses the ALL clause by default and it adds the values, even the duplicates too. But if you want to count only the unique values then you need to use the DISTINCT clause....

Conclusion

SQLite IS NULL function is used to display the null values whereas IS NOT NULL is used to fetch the data that do not have any null values from the table according to the specified query. SQLite SUM function is used to perform the summation on the specified fields and it considers only the null values for the summation and fetches the data accordingly....