In SQL, Operators are special character, symbol or a keyword that is used to perform some specific operations. For example : comparing data
SQL operators are commonly used with SQL statements to retrieve, filter, and manipulate data.
IS NULL operator is used to check if a column contains null or empty rows. It is used in 'WHERE' clause to filter rows based on null values.
SELECT column_name(s) FROM table_name WHERE column IS NULL;
• Specify the column(s) name after the 'SELECT' keyword.
• Specify Asterisk (*) symbol to selects all columns from the table after the 'SELECT' keyword.
• Specify the table name after the 'FROM' keyword.
• Specify the conditions after the 'WHERE' keyword.
• Specify the column_name before the 'IS NULL' keyword to check if rows in that column are null or not.
1. Let's assume we have a table named "[Employees]".
Let's assume you want to retrieve employee data from [Employees] table where employee's gender is empty or null.
Run below SQL statement :
SELECT * FROM [Employees] WHERE Gender IS NULL;
Above statement will retrieve employee data where employee's gender is null or empty.
The "IS NULL" operator in SQL is used to check if a value in a column is NULL.
An example of the null operator is: SELECT * FROM table WHERE column IS NULL;
NULL represents the absence of a value, while an empty condition typically refers to an empty string ('') or a zero-length value.
In SQL, "NULL = NULL" would not return true; you use "IS NULL" to check for null values.