Creating an asp script or function to count duplicate string variables

Hello, I need help on creating an asp script or function to count duplicate string variables and match them to a table variable for that record. I believe I should use the SQL COUNT function but not sure how to implement it! Example below&

I have a string: (1,2,1,5,5,3,3,3,7,4,6,6,3,3,3) these numbers representing record IDs in my SQL DB. I need to pull the records and count how many times its placed in the string and match that number to a table variable to do something with that record. For instants 3 is shown 6 time, so I need to show that record and check that string count agents a table of that record.

Help on this would be greatly appreciated..
inrworxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rg20Commented:
something like this?

select count(*) from table group by recordID
0
inrworxAuthor Commented:
Hello rg20, yes i can use this in the SQL statement, but how do i count up the number in the string first to match it to the records table value?

thanks..
0
inrworxAuthor Commented:
To add to my last comment, I only have a single record in the DB say record id 3. so Im not really grouping in the SQL statement, I think. Im only trying to pull that single record and match the string count to a value in a table from that record. Hope that helps a bit&
0
rg20Commented:
For instants 3 is shown 6 time, so I need to show that record and check that string count agents a table of that record

what you really are asking is
You have a counter for a record that counts how many times a record appears.  you then have a string (as above) in a datafield that you need to query that record.  I think

for example
record ID      counter  
2                     2        
3                     3

table 2
string
1,2,3,1,2,3,3

That would lead me to something like this
select string from table 2
you put this in ASP so I will use some of that here
dim arry()
Dim d
Set d=Server.CreateObject("Scripting.Dictionary")

arry = split(rst("string"),",")
'cycle through the array
for x = 0 to ubound(arry)
http://webcheatsheet.com/asp/dictionary_object.php
use a dictionary here to enter the string elements as the key and increment the counter if the key exists
something like
if key exists
    d.item(arry(x)) = d.item(array(x)) + 1
else
    d.add(arry(x),1)
end if
next
once done, you can get the sums in a string
myItem = allItems(i) 'This is the item value
myitem2 = join(myitem,",")
myitem 2 will be part of the where clause

select recordID from table1 where counter in (myitem2)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
inrworxAuthor Commented:
humm, can i do something like this, tried to do it within the record set:

while not rs.eof
      arry = split(session("track_batchVals"),",")
      boxcount=0
      tracknumid=rs("f_tracknum")'from the record set
      for x = 0 to ubound(arry)
      if tracknumid=x then boxcount=boxcount+1
      next
rs.movenext
wend
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.