tachyon has asked for the wisdom of the Perl Monks concerning the following question:
I have what seems like a pretty simple problem. I want to combine table A with table B to get table C
Constraints.table A tok count a 1 b 1 table B tok count b 1 c 1 table C (desired) tok count a 1 b 2 c 1
What I want to do is encapsulated in this pseudocode
INSERT INTO all_tok (tok, tok1.count+tok2.count) SELECT tok, count from tok1 UNION SELECT tok, count from tok2
I need a union not a join as the final table needa to contain all the toks (at least that is what I think). If a tok exists in one table but not the other I just want the count from the table it exists in. If it does exist in both tables I need the sum of the counts. I have beaten my head against the proverbial wall for some hours. It didn't help, the only good thing was it felt good when I stopped ;-).
Any suggestions about approaches to this seemingly simple task gratefully received. Temp tables are fine.
cheers
tachyon
|
|---|