Let me be more specific about what I'm trying to do. I want to create a query that would generate output like this:
Client Total # Clicks Total # Opt-ins
==== ========== ==========
Bob 5 10
Fred 7 12
This would be easy, except I have two “transaction” – type tables:
Table Clicks keeps track of one type of transaction (in this case, clicking on a link embedded in an email), and Table Opt-Ins keeps track of another type of transaction (in this case, agreeing to become part of an email list). Each of the transaction tables contains a field for Client (actually a pointer to a Client Table).
I can easily display what I want in two separate queries:
#1: SELECT client.name, count(clicks.id) FROM clicks, client WHERE clicks.client=client.id GROUP BY clicks.client
#2: SELECT client.name, count(optins.id) FROM optins, client WHERE optins.client=client.id GROUP BY optins.client
My question: is there a technique to be able to combine the results in a single query so I can display them in a single output table?
In reading some other posts, it seems that a Union of the two queries would give me what I need, but unfortunately, my version of mySQL doesn't support that.