SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    698
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Finding Duplicates

    Is it possible to run a MySQL query that will just find any rows that have the same value as another? Or even to find any where one particular field's value appears more than once in the table?

    Not sure how clear I'm being, so I'll try to explain myself, just in case. Lets assume that the table has allowed duplicate job numbers in a table, and I want to find them all, rather than a particular job number, can I run a query that says something like "SELECT * FROM table WHERE num_rows(job) > 1"???

    Thanks for the help

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,501
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    SELECT jobnumber, COUNT(*)
    FROM table
    GROUP BY jobnumber
    HAVING COUNT(*) > 1

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    698
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Perfect, thanks loads


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
  •