SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    List all duplicate values

    Hi Guys,

    I have many duplicate email address in my table. My current sql get's me the total occurrence for each duplicate value, but I need to list all my duplicate email address so rather than grouping them I just want to list them. Any help appreciated.

    PHP Code:
    SELECT
    FirstName
    ,
    LastName,
    Email,
    count(Email) AS Occurance,
    Company,
    Country,
    FROM dedupe
    GROUP BY Email
    HAVING 
    COUNT(Email) > ); 
    Thanks

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Code:
    SELECT
        d1.FirstName
      , d1.LastName
      , d1.Email
      , d1.Company
      , d1.Country
    FROM dedupe AS d1
    INNER JOIN 
      (SELECT Email
       FROM dedupe
       GROUP BY Email
       HAVING COUNT(*) > 1
      ) AS d2
    ON d1.Email = d2.Email
    ORDER BY d1.Email

  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    Code:
    SELECT
        d1.FirstName
      , d1.LastName
      , d1.Email
      , d1.Company
      , d1Country
    FROM dedupe AS d1
    INNER JOIN 
      (SELECT Email
       FROM dedupe
       GROUP BY Email
       HAVING COUNT(*) > 1
      ) AS d2
    ON d1.Email = d2.Email
    ORDER BY d1.Email
    thanks Guido, Iím running it but its terrible slow....

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Do you have an index on email?

  5. #5
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    Do you have an index on email?
    no index, but it only took about 2 minutes and your sql did the job man

    Graci


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •