How to check Non-Unique, Duplicate or Redundant values in MySql or SQL Table

If you are having a table with huge amount of data, and

  1. want to check that which of the values are duplicate in a field, or which values are redundant, or
  2. 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
HAVING count(id1) > 1;

Where tbl_test is the table, and id1 is the field having redundant or duplicate values.


Leave a Reply

Your email address will not be published. Required fields are marked *