Sometimes we need to check how many duplicate values a column has in MySQL table. We can do this by using "group by" and "having".
Example: Suppose you have a table "user" with "fist_name" column from which you want to find all the records which have duplicate values in column "first_name" then you just need to write the below command
select first_name, count(first_name) from user group by first_name having count(first_name) > 1;
the above command will return all the records having duplicate first_name.
Hope this will help you :)
0 Comment(s)