WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL SELECT DISTINCT Statement


The SQL DISTINCT is used in conjunction with SELECT to eliminate all duplicate records and return only unique ones.


The SQL SELECT DISTINCT Statement

make more sense to return only unique records, instead of fetching the duplicates.

In a table, a column may contain many duplicate values; and sometimes you only want to list the different (distinct) values.

SQL SELECT DISTINCT Syntax

SELECT DISTINCT column_name1,column_name2
FROM table_name;

Example Database

In this tutorial we will use the well-known Northwind sample database.

Below is a selection from the "Customers" table:

CustomerID FastName City Country
1

Jhon Dallas United States
2 Eva Houston United States
3 Maria Texas USA
4

Rajesh Delhi India
5 Stephine LuleƄ UK

SELECT DISTINCT Example

The following SQL statement selects only the distinct values from the "Country" columns from the "Customers" table:

Example

SELECT DISTINCT Country FROM Customers;