Arch Stanton
01-14-2005, 02:34 PM
I am tracking banner clicks and views in 2 tables with the id of the banner and the date the view or click happened. I want to count the number of clicks and views in one query, because I'm lazy.
So this is what I tried:
SELECT COUNT(banner_views.*) AS `views`, COUNT(banner_clicks.*) AS `clicks` FROM banner_views,banner_clicks WHERE banner_views.bannerID='4' AND banner_clicks.bannerID='4';
I am gonna do it it 2 separate queries because I'm pretty sure it's the only way:
SELECT COUNT(*) AS `views` FROM banner_views WHERE banner_views.bannerID='4';
SELECT COUNT(*) AS `clicks` FROM banner_clicks WHERE banner_clicks.bannerID='4';
For future reference, is there another way to do this?
So this is what I tried:
SELECT COUNT(banner_views.*) AS `views`, COUNT(banner_clicks.*) AS `clicks` FROM banner_views,banner_clicks WHERE banner_views.bannerID='4' AND banner_clicks.bannerID='4';
I am gonna do it it 2 separate queries because I'm pretty sure it's the only way:
SELECT COUNT(*) AS `views` FROM banner_views WHERE banner_views.bannerID='4';
SELECT COUNT(*) AS `clicks` FROM banner_clicks WHERE banner_clicks.bannerID='4';
For future reference, is there another way to do this?