SQL Select Distinct

SQL SELECT DISTINCT is used to retrieve unique or distinct data from a table.

DISTINCT is same as UNIQUE and they both return same output.

The syntax of SELECT DISTINCT is

SELECT DISTINCT column1, column2
FROM table_name;

 

Example:

Let us take an example Student table.

1NithinBank StreetHyderabad
2BharathWhite FieldBangalore
3GouthamAvenue colonyChennai

 

SELECT DISTINCT City FROM Student;

 

Now only the unique city data will be displayed.

Hyderabad
Bangalore