In MySQL, the SELECT DISTINCT statement is used to return only distinct values means if in a table, a column has duplicate values then SELECT DISTINCT statement will be used to get different values.
SELECT DISTINCT Syntax
SELECT DISTINCT column_name,column_name
FROM table_name;
We have a table "employee" as below:
employee
id first_name last_name country
.......................................................
1 John Simp Canada
2 Chris Hely Canada
3 John Roy Korea
4 Jenny Mill Korea
5 Jenny Simpson London
SELECT DISTINCT Example
The below statement selects only the distinct values from the "country" columns of the "employee" table:
SELECT DISTINCT country FROM employee;
Result:
Country
...........
Canada
Korea
London
Hope this will help you :)
0 Comment(s)