- Introduction To SQL
- RDBMS
- Data Integrity and Normalization
- Function in SQL
- SQL Syntax
- Data Types
- Operators
- SQL Expressions
- Database
- Tables
- Query
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Select Query
- Update query
- Delete Query
- Distinct Keyword
- Sorting
- Null Values
- Alias Syntax
- Drop a Table
- Alter Table
- Truncate Command
- Clauses
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- Like Clause
- Top Clause
- Order By Clause
- Group By Clause
- Except Clause
- Intersect Clause
- Union Clause
- Union All Clause
- Having Clause
- SQL Constraints
- Joins
- Indexes
- Views
- Transactions
- Date Functions
- Sequences
- Sub Queries
- Handling Duplicates
- SQL Injection
- Stored Procedure
- Triggers
Null Values
How To Use Null Values In SQL
Introduction:
In this article, you will learn what null value is and how to use null values in SQL.
Null value is used to show the unknown value or some data, which will be inserted after some time. Null value can’t consider the null value as blank or zero, because they are different from null value. We count null as a value, but it does not have a fixed value. If we have two or more null values in our table, it is not compulsory that these null values are equal. Because null is unidentified, these values are anything. We use these null values in where clause.
First, we create a table for using “Is Null” or “Is Not Null” values.
Syntax
The basic syntax of null, while creating a table:
create table employee(
Id int not null,
Name varchar (20) not null,
Age int not null,
Address char (25) not null ,
salary decimal ,
primary key (Id)
);
There is only one column, where we did not use not null. It means, these columns can be null.
Example:
In the SQL tables, where we see the null values, these type of tables are always incomplete. We use “Is Null” or “Is Not Null” value in order to check for a null value.
Now, this is an employee table, heaving following records:
- First, we use these records for “Is Not Null operator”
Step 1: Now, we write our query for not null value.
select id, Name, Age, Address, salary from employee where salary is not null ;
Select and execute this query.
Step 2: The output of this query is:
- Now, we use these records for “Is Null operator”
Step 1: Now, we write our query for a null value.
select Id, Name, Age, Address, Salary from employee where salary is null;
Select and execute this query.
Step 2: The output of this query is-
Summary:
Thus, we learned, null value is used to show the unknown value and also learn its use in SQL.