Solved

find duplicates in string in access query

Posted on 2014-09-15
6
482 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

757 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

19 Experts available now in Live!

Get 1:1 Help Now