?
Solved

find duplicates in string in access query

Posted on 2014-09-15
6
Medium Priority
?
502 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 38

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 48

Expert Comment

by:Dale Fye
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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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 38

Accepted Solution

by:
PatHartman earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

800 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