SQL Tutorial: SQL SELECT DISTINCT Instance 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.
SQL SELECT DISTINCT syntax.
SELECT DISTINCT column_name (s) from
table_name
Let's take a look at an example of a distinct record.
| _id |
lastname |
firstname |
address |
city |
| 1 |
Hansen |
ola |
timoteivn |
S Andnes |
| 2 |
svendson |
Tove |
borgvn |
Sandnes |
| 3 |
Pettersen |
Kari |
storgt |
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 results are as follows.