$query=$this->db->select('*') ->from('activation') ->join('products','products.id_pro = activation.id_pro') ->join('user','user.id = products.user_p') ->order_by('id_key','DESC') ->get();
return $query->result();
I have these code where I join result from 3 tables abd that works good. What I need more is counted rows from 4.table. That table is called license, and I need to count how many rows are with id_key (primary key for table activation). How to add that in my code?
Try selecting license column as count
$query=$this->db->select('*, COUNT(license.id_key ) as license_count')
->from('activation')
->join('products','products.id_pro = activation.id_pro')
->join('user','user.id = products.user_p')
->join('license','license.id_key = table.column?')
->order_by('id_key','DESC')
->get();
access the count within the object like: $query->result()->license_count;