Find MYSQL Duplicate records

In : mysql, Posted by on Mar.03, 2009

If the database has a table call employees. The values are:


ID           Name
1              a
2              b
3              a
4              c
5              b

You want to find the duplicate record but not the first one (ie, ID# 3 and 5). You can do the following:

select id from employees where id not in (select distinct id from employees group by name);

No comments for this entry yet...