SQL Select Distinct

SQL Select Distinct is used to retrieve unique data from table.
There are chances of duplicate entry in database tables, for finding unique values DISTINCT command is used.

Syntax


SELECT DISTINCT column_name FROM table_name;



Take Table name Student
ID Name Age City
1 Rahul 20 Pathankot
2 Karan 24 Mohali
3 Ajay 22 Pathankot
4 Ravi 23 Delhi



SELECT DISTINCT City FROM Student;



Output

City
Pathankot
Mohali
Delhi

Back To Top