SQL SELECT DISTINCT Statement

There are some cases where a table contains duplicate records, this is where the SQL SELECT DISTINCT statement comes in handy. The SQL SELECT DISTINCT statement is used to return the distinct records with duplicate values.

The DISTINCT keyword is added to the SELECT statement to return the distinct records with duplicate values.

SQL SELECT DISTINCT statement

SELECT DISTINCT column_name(s)

FROM table_name


Database Table “Members”

Id FirstName LastName Email City Phone
1 Gilbert Duncan [email protected] Newark 973-600-3300
2 Elvis Daniels [email protected] Piscataway 862-600-3050
3 Michael Green [email protected] Detroit 732-500-5050
4 Kelvin Graham [email protected] Detroit 732-555-5050

SQL SELECT DISTINCT Example

SELECT DISTINCT City

FROM Members

RESULT of SQL SELECT DISTINCT statement above will be

City
Detroit
Detroit