SQL SELECT DISTINCT Syntax and usage tutorial
This chapter will explain the choice of discrete speakers.
Select a different declaration in SQL
In one table, some columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (different) values on the table.
Unique keywords can be used to return only unique (different) values.
Choose a different SQL syntax
SELECT DISTINCT column_name (s) from
table_name
Choose a different role model
In the person table:
p_id |
LastName |
FirstName |
| Address
| City
1 |
Hansen |
Ola |
TIMOTEIVN 10 |
Sandnes |
2 |
Svendson |
Tove |
BORGVN 23 |
Sandnes |
3 |
Pettersen |
Kari |
STORGT 20 |
Stavanger |
Now, we want to select only the different values from the column named "City" from the above table.
We use the following SELECT statement:
select DISTINCT City from Persons
The result-set would look like this :
Note: Reprint please indicate from www.111cn.net/database/database.html