I am new to codeigniter, I would like to ask some help. How can I convert this mysql query into a codeigniter active record. This is my query
SELECT p.*, s.product_id,sum(s.quantity) as st, sumq,
sum(s.quantity) - sumq as a, concat (prod_desc,' ',brand_name) as names
from stocks s join ( select product_id, sum(quantity) sumq
from order_details group by product_id) o on s.product_id = o.product_id join (select * from products) p on p.prod_id = s.product_id
join (select * from brand) b on b.brand_id = p.brand_id
group by product_id having a >= 1