MySQL DISTINCT clause
SYNTAX
SELECT DISTINCT
columns
FROM
table_name
WHERE
where_conditions;
Table structure Used for Example explanation
For the example country table is used .The structure of country table is as follow:
+—————-+————+
| Field | Type |
+—————-+————+
| Code | char(3) |
| Name | char(52) |
| Continent | char(40) |
| Region | char(26) |
| SurfaceArea | float(10,2)|
| IndepYear | smallint(6)|
| Population | int(11) |
| LifeExpectancy | float(3,1) |
| GNP | float(10,2)|
| GNPOld | float(10,2)|
| LocalName | char(45) |
| GovernmentForm | char(45) |
| HeadOfState | char(60) |
| Capital | int(11) |
| Code2 | char(2) |
+—————-+————+
Example for MySQL DISTINCT clause
Select Distinct continent from country ;
Output of Above Example
mysql> Select Distinct continent from country ;
+—————+
| continent |
+—————+
| Asia |
| Europe |
| North America |
| Africa |
| Oceania |
| South America |
| Antarctica |
+—————+
7 rows in set (0.07 sec)