"Fossies" - the Fresh Open Source Software Archive

Member "drizzle-7.1.36-stable/docs/distinct.rst" (6 May 2012, 1155 Bytes) of package /linux/misc/old/drizzle-7.1.36-stable.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

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:

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:

SELECT DISTINCT City FROM Persons;

The result-set will look like this:

City
Chicago
Reno