~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
DISTINCT
========

In a table, columns may contain more than one of the same value. 

Sometimes it's helpful to list only the different, distinct values in a table; in this case the DISTINCT keyword can be used.

SQL SELECT DISTINCT Syntax: 

.. code-block:: mysql

	SELECT DISTINCT column_name(s)
	FROM table_name

**SELECT DISTINCT Example**

The "Persons" table:

+---------+------------+----------+----------+--------+
|Id 	  |LastName    |FirstName |Address   |  City  |
+=========+============+==========+==========+========+
| 1 	  | Larson     | Sue      |3 Cherry  | Chicago|
+---------+------------+----------+----------+--------+
| 2 	  | Roberts    | Teri 	  |21 Brown  | Chicago|
+---------+------------+----------+----------+--------+
| 3 	  | Peterson   | Kari 	  |30 Mell   | Reno   |
+---------+------------+----------+----------+--------+

In order to select distinct values from the column named "City" from the table above, use the following SELECT statement:

.. code-block:: mysql

	SELECT DISTINCT City FROM Persons;

The result-set will look like this:

+--------+
|City    |
+========+
|Chicago |
+--------+
|Reno    |
+--------+