SQL Null operator
Description
SQL Null check is performed using either IS NULL or IS NOT NULL to check whether a value in a field is NULL or not.
When a field value is NULL it means that the database assigned nothing in that field for that row. The NULL is not zero or blank. It represents an unknown or inapplicable value. It can’t be compared using AND / OR logical operators. The special operator ‘IS’ is used with the keyword ‘NULL’ to locate ‘NULL’ values. NULL can be assigned in both type of fields i.e. numeric or character type of field.
Syntax
SELECT [column_name1,column_name2 ]
FROM [table_name]
WHERE [column_name] IS [NOT] NULL;
Parameters
| Name | Description |
|---|---|
| column_name,column_name1.. | Name of the column of the table. |
| table_name | Name of the table. |
Example
Sample table : listofitem
To get data of all columns from the 'listofitem' table with following condition -
1. coname column contain NULL value,
the following sql statement can be used :
SELECT * FROM listofitem WHERE coname IS NULL;
Output

Sql Not null operator
Sample table : listofitem
To get data of all columns from the 'listofitem' table with the following condition -
1. 'coname' column must have a value,
the following sql statement can be used :
SELECT *
FROM listofitem
WHERE coname IS NOT NULL;
Output

Outputs of the said SQL statement shown here is taken by using Oracle Database 10g Express Edition.

