How to remove duplicate data in a MySQL query?

In MySQL, you can use the DISTINCT keyword to query for unique data.

For example, suppose there is a table called “employees” that contains the following data:

+----+-------+--------+
| id | name  | salary |
+----+-------+--------+
| 1  | John  | 5000   |
| 2  | Jane  | 6000   |
| 3  | John  | 5000   |
| 4  | Peter | 5500   |
+----+-------+--------+

To search for duplicate entries in the name column, you can use the following statement:

SELECT DISTINCT name FROM employees;

After executing this query, the result set will return the unique values in the name column.

+-------+
| name  |
+-------+
| John  |
| Jane  |
| Peter |
+-------+

Please note that the DISTINCT keyword eliminates duplicates from all columns in the query result set. If you only want to remove duplicates from specific columns, just specify those columns in the SELECT clause.

bannerAds