SQL DISTINCT Keyword
The SELECT DISTINCT command returns only distinct or different values in the result set. It is used to eliminate duplicate entries and show only one instance of each unique value.
SQL DISTINCT Syntax
SQL
x
1
SELECT DISTINCT column1, column2, ...
2
FROM table_name;
SQL DISTINCT Example
The following SQL statement selects only the distinct values from the gender
column in the Patients
table, This will return a list of all unique values found in the gender column such as F
or M
without repeating them:
SQL
1
1
SELECT DISTINCT gender FROM Patients;
