update statistic2 set hits = hits + (select count(*) from content_hit as h1 where statistic2.user_id=h1.user_id and statistic2.content_id = h1.content_id), unique_hits = unique_hits + (select sum(numips) from (select count(distinct(h2.ip)) as numips from content_hit as h2 where content_hit.user_id=statistic2.user_id and content_hit.content_id=s.content_id and posted=1 and valid=1 group by year(created_date), month(created_date), day(created_date)) v1 ), clicks = clicks + (select count(*) from content_click as c1 where statistic2.user_id=c1.user_id and statistic2.content_id = c1.content_id), unique_clicks = unique_clicks + (select sum(numips) from (select count(distinct(c2.ip)) as numips from content_click as c2 where c2.user_id=statistic2.user_id and c2.content_id=statistic2.content_id and active=1 group by year(created_date), month(created_date), day(created_date) ) v2);