I am counting clicks per category of ads. I am curently passing category to function, I have 10 cats, so I am calling this function 10 times to get number of clicks for each category. So i am trying to figure out is it possible to do in one query. Just started with mysql This is my code:
SELECT SUM(clicks) AS 'clicks' FROM wp_cb_ads_manager WHERE category = '.$cat.'
and this gives me
Array ( [0] => stdClass Object ( [clicks] => 11 ) )
Is it possible to do this on one query, so to retrieve SUM per each category in array. Here is the screen of how 2 tables looks like:
http://awesomescreenshot.com/00018kly6d http://awesomescreenshot.com/06418kltcc
In first i keep list of categories, and in second I keep ads where one field is used to check in which category is ad.