Devo fare una tabella (in MySQL) di statistiche che conta gli elementi degli array inseriti in un'altra tabella e conta quali sono gli elementi che si ripetono più spesso...

Mi spiego meglio: nella tabella A ho il nome del cliente in una colonna e i suoi acquisti fatti sotto forma di array in un'altra colonna (articolo1,articolo2,articolo3, ecc...).

Nella tabella B invece devo inserire quante volte per esempio l'articolo1 è stato acquistato, quindi contare quante volte quel codice articolo si ripete nella tabella A.
codice:
set rs = Server.CreateObject("ADODB.recordset")
SQL = "SELECT * FROM archord"
set rs = objCon.execute(SQL)

set rs7 = Server.CreateObject("ADODB.recordset")
SQL7 = "SELECT codart FROM archord"
set rs7 = objCon.execute(SQL7)

do while not rs.eof

	arrCod = split(rs("codart"),",")
	
	for i = 0 to ubound(arrCod) - 1
	
		for each arrCod(y) = arrCod(i)
			totVenduti = totVenduti + 1
		next
			
		set rs2 = Server.CreateObject("ADODB.recordset")
		SQL2 = "SELECT * FROM top3prod WHERE codart = '"&arrCod(i)&"'"
		set rs2 = objCon.execute(SQL2)
						
		if not rs2.eof then
				
			if totVenduti = "" then
				totVenduti = 1
			end if
							
			set rs3 = Server.CreateObject("ADODB.recordset")
			SQL3 = "UPDATE top3prod SET venduti = '"&totVenduti&"' WHERE codart = '"&arrCod(i)&"'"
			set rs3 = objCon.execute(SQL3)

		else
		
			set rs4 = Server.CreateObject("ADODB.recordset")
			SQL4 = "SELECT * FROM newecom WHERE (codart = '"&arrCod(i)&"')"
			set rs4 = objCon.execute(SQL4)
			
			if rs4("clin1") <> "38" and rs4("clin1") <> "41" AND rs4("clin1") <> "25" then
			
				set rs5 = Server.CreateObject("ADODB.recordset")
				SQL5 = "SELECT * FROM l1cat WHERE codcat = '"&rs4("clin1")&"'"
				'response.end
				set rs5 = objCon.execute(SQL5)
			
				set rs6 = Server.CreateObject("ADODB.recordset")
				SQL6 = "SELECT * FROM l1prod WHERE codprod = '"&rs4("cpro")&"'"
				'response.write sql6
				'response.end
				set rs6 = objCon.execute(SQL6)
				
				desArt = split(rs4("desart"),"+")
		
				set rs3 = Server.CreateObject("ADODB.recordset")
				SQL3 = "INSERT INTO top3prod (codart, desart, cat, prod, venduti) VALUES ('"&arrCod(i)&"','"&desArt(0)&"','"&rs5("titcat")&"','"&rs6("titprod")&"',1)"
				set rs3 = objCon.execute(SQL3)
		
			end if
		
		end if
		
		response.write arrCod(i)&"
"
	
	next

rs.movenext
y = y + 1
loop
Naturalmente il codice non funziona...non riesco a contare quante volte un codice si ripete nella tabella A...aiuto!!!