i have some records in a table. some of them have duplicated value in a field. i want to extract these duplicated values with mysql commands. how can i do that?
+1
A:
You mean something like: I have a Person table, and there are multiple person with the same name, I want to find them?
You can do that using a group by clause:
select p.name, count(p.name) c
from person p
group by p.name
having count(p.name) > 1
If you want to check duplicate multiple columns, then add all of them to the select
and group by
select p.name, p.age, p.sex, count(*) c
from person p
group by p.name, p.age, p.sex
having count(*) > 1
Nivas
2010-10-12 08:00:13
thanks,that is exactly what i need.
hd
2010-10-12 08:02:50