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 NOT NULL operator is used to check if a column contains non-null or non-empty rows. It is exact opposite of 'IS NULL' operator and used in 'WHERE' clause to filter rows based on non-null rows.
SELECT column_name(s) FROM table_name WHERE column IS NOT 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 NOT NULL' keyword to check if rows in that column are non-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 non-empty or non-null.
Run below SQL statement :
SELECT * FROM [Employees] WHERE Gender IS NOT NULL;
Above statement will retrieve employee data where employee's gender is non-null or non-empty.
The NOT NULL operator in SQL ensures that a column cannot have a NULL value.
In SQL, "IS NOT NULL" checks if a column value is not NULL.
"IS NOT NULL" and "!= NULL" both check for non-NULL values, but the former is more explicit and preferred.
In SQL, specify "NOT NULL" constraint when defining a column to ensure it cannot contain NULL values.