SQL SELECT DISTINCT Keyword
The SELECT DISTINCT command is used to return only unique (different) values from a column or combination of columns in the result set.
SQL SELECT DISTINCT Syntax
SQL
x
1
SELECT DISTINCT column1, column2, ...
2
FROM table_name;
SQL SELECT DISTINCT Single Column Example
This query selects unique gender values from the Patients
table.
SQL
1
1
SELECT DISTINCT gender
2
FROM Patients;

SQL SELECT DISTINCT Multiple Columns Example
This query selects unique combinations of doctor_id
and specialty
from the Doctors
table.
SQL
1
1
SELECT DISTINCT doctor_id, specialty
2
FROM Doctors;
