Solved

find duplicates in string in access query

Posted on 2014-09-15
6
493 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 36

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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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 36

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

821 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