Hi,
I have alot of data and im trying to speed things up by making some summary tables.

My summary_totals table has:
id, websiteid, hits, visitors

This will contain the websiteid, total hits and total visitors.

My hits table has (there are many more fields, but they are not relevant to this)
id, websiteid

My visitors table has (there are many more fields, but they are not relevant to this):
id, websiteid


So this works:
INSERT INTO summary_totals (websiteid, hits) SELECT websiteid, count(id) FROM hits 
GROUP BY websiteid;

And gives me a new table with the websiteid and total hits for each websiteid but how 
do i add the visitors total?

To get the visitors total I do:
SELECT websiteid, count(id) FROM visitors WHERE websiteid = X

How can I get this total into the summary table? Using an update somehow? or as part 
of the insert?

Reply via email to