4
In a table, columns may contain more than one of the same value.
6
Sometimes it's helpful to list only the different, distinct values in a table; in this case the DISTINCT keyword can be used.
8
SQL SELECT DISTINCT Syntax: ::
10
SELECT DISTINCT column_name(s)
13
**SELECT DISTINCT Example**
17
+---------+------------+----------+----------+--------+
18
|Id |LastName |FirstName |Address | City |
19
+=========+============+==========+==========+========+
20
| 1 | Larson | Sue |3 Cherry | Chicago|
21
+---------+------------+----------+----------+--------+
22
| 2 | Roberts | Teri |21 Brown | Chicago|
23
+---------+------------+----------+----------+--------+
24
| 3 | Peterson | Kari |30 Mell | Reno |
25
+---------+------------+----------+----------+--------+
27
In order to select distinct values from the column named "City" from the table above, use the following SELECT statement: ::
29
SELECT DISTINCT City FROM Persons;
31
The result-set will look like this: