-
SQL Installing SSMS
-
SQL Syntax
-
SQL Datatype
-
SQL Database
-
SQL Table
-
SQL Select
-
SQL Distinct
-
SQL Count
-
SQL Top
-
SQL Aliases
-
SQL In
-
SQL Insert
-
SQL Update
-
SQL Null
-
SQL Like
-
SQL Wildcards
-
SQL Nested Query
-
SQL Between
-
SQL Unique
-
SQL Primary Key
-
SQL Foreign Key
-
SQL Check
-
SQL Default
-
SQL Database Diagram
-
SQL Stored Procedures
-
SQL Joins
-
SQL Inner Join
-
SQL Left Join
-
SQL Right Join
-
SQL Full Join
-
SQL Trigger
SQL Null
First of all we should know what a null value is. Null values are used to represent missing unknown data. A NULL value is different from a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation!
There can be two conditions:
- Where SQL is NULL
- Where SQL is NOT NULL
It is not possible to test for NULL values with comparison operators, such as =, <, or <>.
We will have to use the IS NULL and IS NOT NULL operators instead.
Example:
SHOW ME the names of people in the IT department.
SELECT column_names FROM table_name WHERE column_name IS NOT NULL;
There is an example of student table:
Let’s see the query to get all the records where marks is NULL:
SELECT SIR_NAME, NAME, MARKS FROM STUDENTS WHERE MARKS IS NULL ;
It will return the following records:
Let’s see the query to get all the records where marks is NOT NULL:
SELECT SIR_NAME, FIRSTNAME, MARKS FROM STUDENTS WHERE MARKS IS NOT NULL;
It will return the following records:
Course Video
1. Write SQL Query to get all the columns from Person.Person table where title is not null.
OUTPUT
2. Write SQL Query to get BusinessEntityID, TerritoryID, Bonus From Sales_SalesPerson where SalesQuota IS NULL
OUTPUT
3. Write SQL Query to get BuinessEntityID, PersonType from Person.Person Where title is Null.
OUTPUT
4. Write a SQL Query to get all the columns from Person.Person where suffix is Null.
OUTPUT
5. Write Sql query to get all the columns from Sales.SalesPerson table where TerritoryId is null.
OUTPUT
YouTube Reference :
1) SQL Null in Hindi/Urdu
2) SQL Null in English