SQL Commands


SQL NULL Tutorial

SQL NULL value represents a blank value in a table. NULL value is used for identifying any missing entries in a table.

One can use NOT NULL value to display table entries which are not NULL.

Syntax of NULL Value

SELECT column_name(s)
FROM table_name
Where column_name IS NULL;

SELECT column_name(s)
FROM table_name
Where column_name IS NOT NULL;

SQL NULL STATEMENT Example:

Database table “Employee”

Employee IDEmployee NameAgeGenderLocationSalary
1001Henry54MaleNew York100000
1002Tina36FemaleMoscow80000
1003John24Male 40000
1004Mile31MaleLondon70000
1005Tara26Female 50000
1006Sohpie29FemaleLondon60000

Note: "Location" column in the "Employee" table above is optional. Therefore, if one enters a data with no value for the "Location" column, the "Location" column will be saved with a NULL value.

Now if one wants to display the entries whose location is left blank, then here is a statement example.

SELECT * FROM Employee
WHERE Location IS NULL;

SQL NULL Statement Output:

The NULL statement will display the following results

Employee IDEmployee NameAgeGenderLocationSalary
1003John24Male 40000
1005Tara26Female 50000

SQL NOT NULL Statement

Now one wants to display the field entries whose location is not left blank, then here is a statement example.

SELECT * FROM Employee
WHERE Location IS NOT NULL;

SQL NOT NULL Statement Output:

The NOT NULL statement will display the following results

Employee IDEmployee NameAgeGenderLocationSalary
1001Henry54MaleNew York100000
1002Tina36FemaleMoscow80000
1003John24MaleLondon40000
1006Sophie29FemaleLondon60000

BookMark This Page




Translate Your SQL Pages
100 + Languages

EnglishFrenchGermanItalianPortugueseRussianSpanish