Need query to find potential duplicate names

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • livewiremce
    New Member
    • Dec 2012
    • 3

    Need query to find potential duplicate names

    Hello,

    I need help to modify a query in MS Access 2010 - I need to find duplicates in [FIELD NAME] where they start with the same 5 letters. I created a regular "find duplicates query" but then I cannot figure out how to modify to make it locate ALL the entries that START with the same 5 characters.

    Code:
    In (SELECT [Field Name] FROM [TABLE] As Tmp GROUP BY [Field Name] HAVING Count(*)>1 )
    Last edited by NeoPa; Dec 19 '12, 02:15 AM. Reason: Please use the mandatory [CODE] tags.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    It looks like you just need a little bit more in your SQL LiveWire. try out :
    Code:
    SELECT   [Field Name]
    FROM     [Table]
    WHERE    Left([Field Name],5) In (
        SELECT   Left([Field Name],5)
        FROM     [Table]
        GROUP BY Left([Field Name],5)
        HAVING   Count(*)>1)

    Comment

    • livewiremce
      New Member
      • Dec 2012
      • 3

      #3
      It worked like a charm. Thanks!

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        I'm pleased it worked. The real question is whether or not it makes sense to you. If not then we should work on that ;-)

        Comment

        • livewiremce
          New Member
          • Dec 2012
          • 3

          #5
          It totally does - I am relatively new to this kind of stuff so i could not figure out the syntax. Thanks for your help!

          Comment

          Working...