Finding duplicates in an msaccess table

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Finding duplicates in an msaccess table

    Hi,

    I have a table with members first name and last name. I would like to scan the
    table for duplicate names. The table has no indexes (if that means anything). I
    can easily order the table by first_name, last_name and work through each row,
    but that would be intolerably slow (there are 1500 rows on the table).

    Does anyone know a way to quickly find duplicates?

    Thanks
    Tanya

    Rustywater Guest

  2. Similar Questions and Discussions

    1. Finding duplicates without primary key
      Hi, is there a way to find all duplicates in a table without a primary key? Regards, André
    2. Finding duplicates
      Hi, didn't think that this could be so tricky. ;) I have a table: ID, Cycle, Name, Institution, Phone, Fax There are entries that have...
    3. MSACCESS hangs when retrieving LIST type field (linked informix table)
      I have fields like: ,field LIST(VARCHAR(255) NOT NULL) NOT NULL MSACCESS hangs when i retrieve this via a linked table. I also have fields...
    4. INSERT creates duplicates in linking table
      No, insert cannot include a where clause. If you need to prevent duplicates you should define a unique index on the desired columns and either...
    5. Removing Duplicates from a table..
      Simple question here.. I want to a query to remove the duplicates from a table and leave only 1 of them.. The entire record is duplicated so there...
  3. #2

    Default Re: Finding duplicates in an msaccess table

    Someting like this might get you going in the right direction.

    SELECT t.first_name, t.last_name
    FROM table t
    WHERE EXISTS(SELECT 1
    FROM table t2
    WHERE t.first_name = t2.first_name
    AND t.last_name = t2.last_name
    HAVING COUNT(*) > 1)


    paross1 Guest

  4. #3

    Default Re: Finding duplicates in an msaccess table

    Phil's query is absolutely correct. I just wanted to add, since you mentioned Access, that Access has a wizard for exactly this kind of query.

    JR

    jonwrob Guest

  5. #4

    Default Re: Finding duplicates in an msaccess table

    The records are on a single table. Translating your suggestion into the code
    for cf I get this (does it look right). #dupes.recordcount# returns the same
    value as the number of rows on the table (1486). I know for a fact that there
    are only 6 duplicates on the table. (btw; uid_user is just the users account
    number)

    I'm not very good with SQL (obviously), but this did look to make sense that I
    got the result that I got... It's like saying if 1=1.. So the penny hasn't
    dropped yet. What am I doing wrong?



    <cfquery name="dupes" Datasource="#Application.datasource#">
    SELECT users.first_name, users.last_name, uid_user
    FROM users
    WHERE EXISTS(SELECT 1
    FROM users
    WHERE users.first_name = users.first_name
    AND users.last_name = users.last_name
    HAVING COUNT(*) > 1)
    </cfquery>

    Rustywater Guest

  6. #5

    Default Re: Finding duplicates in an msaccess table

    You have a problem in your correlated subquery because you are not
    differentiating the table name between the outer and inner queries.

    Phil


    <cfquery name="dupes" Datasource="#Application.datasource#">
    SELECT u1.first_name, u1.last_name, u1.uid_user
    FROM users u1
    WHERE EXISTS(SELECT 1
    FROM users u2
    WHERE u1.first_name = u2.first_name
    AND u1.last_name = u2.last_name
    HAVING COUNT(*) > 1)
    </cfquery>

    paross1 Guest

  7. #6

    Default Re: Finding duplicates in an msaccess table

    Thanks so much Phil. this works beautifully.

    tanya
    Rustywater Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139