MySQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

MySQL Duplicates

MySQL Duplicates

shape Description

MySQL Duplicates are used to eliminate duplicate values in a column. And these duplicates values an be eliminated using different number of functions such as distinctClause, primary key Constraints or unique Constraints.

shape Syntax

The syntax for MySQL Duplicates is as follows:
Select DISTINCT from <table>;
table_name => Any accurate table. column_name => The condition that one can perform on a column by using distinct clause.

shape Examples

By viewing the below example, the concept of MySQL Duplicates clause can be easily understood. [sql]mysql> select * from employee; +--------+-------+-------+--------+ | emp_id | ename |salary | deptno | +--------+-------+-------+--------+ | 1001 | mike | 12000 | 10 | | 1002 | rambo | 13000 | 20 | | 1003 | kate | 14000 | 10 | | 1003 | jeo | 14000 | 20 | | 1003 | finn | 14000 | 30 | +--------+-------+-------+--------+ 5 rows in set (0.00 sec) mysql> select distinct deptno from employee; +--------+ | deptno | +--------+ | 10 | | 20 | | 30 | +--------+ 3 rows in set (0.00 sec)[/sql] The above example tells that, when distinct clause operation is performed on a column deptno, then it displays the values of jeo, finn, and kate as they have the maximum salary and automatically remove duplicate values of mike and rambo as they having minimum salary.

Summary

shape Key Points

  • MySQL Duplicate - Are used to eliminates duplicate values in a column.