Solved

find duplicates in string in access query

Posted on 2014-09-15
6
484 Views
Last Modified: 2014-09-15
I need to write a  query that will identify if a string has duplicate words in it.

am in access query grid

not sure how.
0
Comment
Question by:PeterBaileyUk
  • 3
  • 2
6 Comments
 
LVL 34

Expert Comment

by:PatHartman
ID: 40323154
You can't do this with just a query.  You'll need to write a function that finds the duplicates.  You can then call the function from your query and select rows where the count is >1 or true or whatever you have your function return when it finds duplicates.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40323156
Peter, can you give an example?

"now is the time for all good men to come to the aid of their country"

this has 2 "to" and 2 "the",  but is that what you have in mind?  Do you need to do this in a query? is a function OK? are you looking for duplicates of any word, or just specific words?
0
 

Author Comment

by:PeterBaileyUk
ID: 40323163
"hello fred fred how are you"
"hello 110 this is 110 fred"

"this is fred and fred and fred a lots of them"
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:PeterBaileyUk
ID: 40323168
duplicates of any word. I dont need to know what they are just that a duplicate occurred for now.
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40323208
I don't have the time to write this for  you (and that isn't our job here anyway) but one possible method is to use the split() function to split out all the words into individual array entries.  Then you loop through the array in the outer loop to pick up the next word and in the inner loop to find any duplicates.  However, you will probably want to make the loop smarter and once you have found how many instances of Fred exist, not allow the next instance of Fred in the outer loop to trigger the scan of the array again.

You also need to decide if you will exit the loop once you find ANY duplication (easiest) because if you need to report multiple sets of duplicates, you have to now create an array or table to hold them and some way to report on them.
0
 

Author Closing Comment

by:PeterBaileyUk
ID: 40323397
ok i will word around array
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

911 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

20 Experts available now in Live!

Get 1:1 Help Now