MySQL: Check for douplicates

Posted on 2011-10-07
Last Modified: 2012-05-12
Using a MySQL query, I want to find all records from the table `zoo` where the value of `foobar`occurs exactly the same more than once.


Open in new window

Question by:hankknight
    LVL 51

    Accepted Solution


    select * from zoo where id foobar in (
      select foobar FROM zoo group by foobar having count(1) > 1

    Assisted Solution

    For counting duplicate records

    SELECT COUNT(*) as repetitions, foobar FROM zoo GROUP BY foobar HAVING repetitions > 1;

    For fetching all same occurance records

    SELECT b.* FROM zoo a INNER JOIN zoo b ON a.foobar = b.foobar WHERE <>;

    Here assuming id is the colum for zoo table.
    LVL 142

    Assisted Solution

    by:Guy Hengel [angelIII / a3]
    not exactly the answer, but surely you will want to read that up also:

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now