I am going to make some graphs/stats with visitors stats I have collected. The part of the database that I am grabbing data from is from two tables (more eventually after I get the hang of joins).
track
id int(11)
site_id smint(6)
query_id medint(9)
campaign_id tinyint(4)
hit_type tinyint(4)
0::raw
1::uniques
2::raw_out
3::unique_out
hit_cat tinyint(4)
0::main
1::gateway
2::site
3::category
4::webcam
user_id int(11)
date datetime
query
id medint(9)
query varchar(120)
code varchar(6)
campaign_id tinyint(4)
type_id smallint(6)
0::non cat
1::category
domain_id smallint(6)
ref_id medint(9)
*/
This is part of my new db layout (I rushed into the script last time without much forethought and ended up not collecting enough data to join tables together, a few days later, lesson learned I hope

)
Ok so what I want to be able to do is join them together by query_id where track.date > '$yesterday' which I can do already. The part that I am a bit confused on is that I want to GROUP BY track.hit_cat and then get the count for each hit_type for each of those. This way I can see what visitors do at the site when they come in from different search terms (grabbed from the referrer). I think I should be able to do this in one select with a join for each hit_type (eg WHERE hit_type = 0). Anyways should I just make four queries and put the results from each query in a multidimensional array and be done with it, or is it doable with joins.
I hope someone can understand what I am saying, if not let me know and I will wait till the drugs wear off

Thanks!
jsp