Facebook

Выражайтесь красиво. SELECT c.*, SUM(l.payment) AS payment, @fee := ( SELECT masterfee FROM users_meta WHERE `user` =».$CI->session->userdata(‘id’).» ) AS fee, @cnt := ( SELECT COUNT( id ) FROM links AS lc WHERE lc.status=9 AND c.id = lc.campaign_id ) AS cnt, @rej := ( SELECT count(id) FROM links AS lc2 WHERE lc2.campaign_id = c.id AND lc2.status = 4 OR lc2.status = 5 ) AS rejected FROM campaign AS c LEFT JOIN links AS l ON c.id = l.campaign_id AND l.status = 9 WHERE ( c.active =1 OR c.active =0 OR c.active =2 ) AND c.owner =».$CI->session->userdata(‘id’).» GROUP BY l.campaign_id