Sql NULL Values
What is NULL value?


The SQL NULL is the term used to represent a missing value. A field with a NULL value is a field with no value.
If in a table for any column you don't want to insert any value Then the field will be saved with a NULL value.
It is very important to understand that a NULL value is different than zero value or a field that contains spaces.
HOW TO TEST FOR NULL VALUES:-
It is not possible to test for NULL values with comparison operators ,such as = , > ,< or < > .
So you will have to use IS NULL and IS NOT NULL operators instead.
SYNTAX:-
IS NULL SYNTAX:-
SELECT column_names
FROM table_name
WHERE column_name IS NULL;
IS NOT NULL SYNTAX:-
SELECT column_names
FROM table_name
WHERE column_name IS NOT NULL;
Consider the following EMPLOYEE table having the records as shown below:-
The IS NULL Operator:-
The IS NULL operator is used to test for NULL values.
The following example lists all EMPLOYEE with a NULL value in the "SALARY" field:-
EXAMPLE:-
SELECT NAME, AGE ADDRESS
FROM EMPLOYEE
WHERE SALARY IS NULL;
OUTPUT:-
The IS NOT NULL Operator:-
The IS NOT NULL operator is used to test for non-empty values.
The following Example lists all EMPLOYEE with a NULL value in the "SALARY" field:-
EXAMPLE:-
SELECT ID, NAME, AGE, ADDRESS, SALARY
FROM EMPLOYEE
WHERE SALARY IS NOT NULL;
OUTPUT:-
Comments
Post a Comment