If you are having a table with huge amount of data, and
- want to check that which of the values are duplicate in a field, or which values are redundant, or
- want to make a field as unique, but don’t know how much data is redundant or duplicate to make it remove first, and then make it unique, then the following query will help you in finding the duplication or redundant values in a table:
SELECT id1 FROM tbl_test
GROUP BY id1
HAVING count(id1) > 1;
SELECT id1 FROM tbl_test GROUP BY id1 HAVING count(id1) > 1;
Where tbl_test is the table, and id1 is the field having redundant or duplicate values.