Loading, please wait...

Distinct Keyword

How To Use Distinct Keyword In SQL

Introduction:
In this article, you will learn, what distinct keyword is and how to use a distinct keyword in SQL.
The distinct keyword is used to remove the duplicate element from the table and retrieve the similar data.

 

Syntax

The basic syntax of the distinct keyword is as follows:

select column1, column2,.... from table_name order by column_name;

 

 

Example

Step 1: Now, see how this query returns the duplicate salary records:

 

 

 

Select and execute this query.

 

Step 2: The result of this query will be:

 

 

 

Now, we create the query with a distinct keyword, using select query. The syntax of this query is as follows:

 

 

Syntax

select distinct column1, column2,.... from table_name where [condition];

 

 

Step 3: We write our query.

 

 

 

Select and execute this query.

 

Step 4: The result of this query will be:

 

 

 

Summary:
Thus, we learned that distinct keyword is used to remove the redundancy from SQL tables.