PHP - advice for java HashMap alternative in php?

Posted by teutara on Stack Overflow See other posts from Stack Overflow or by teutara
Published on 2012-11-26T16:40:18Z Indexed on 2012/11/26 17:04 UTC
Read the original article Hit count: 172

Filed under:
|
|

I know it is super noob and will be answered in no time, but I could not figure.. sorry for any inconvenience.. Here is the thing:

ID  colA    colB    Length
1   seq1    seq11   1   
2   seq1    seq11   11  
3   seq3    seq33   21  
4   seq3    seq33   14  

I have a db with this kind of a table, has more than 10M rows. I want to loop though colA first, get the relevant colB value, and check if there are any other occurrences of the same value. For example in colB (seq11) there are 2 occurrences of colA(seq1), this time I have to combine those and output the sum of the length. Similar to this:

ID  colA  colB   Length
1   seq1  seq11  12
2   seq3  seq33  35

I am a bit java guy, but because my colleague has written everything in php and this will be just an adding, i need a php solution. With java i would have used hashmap, so that I would have the colA data once and just increment the value of "Length Column"..

I know it is not a proper question, but.. Thank you in advance..

$$$$$$$$$$ EDIT $$$$$$$$$$

I tried this query in order to group by occurences:

SELECT COUNT(*) SeqName FROM SeqTable GROUP BY SeqName HAVING COUNT(*)>0;

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql