I was wondering how can I make a query that will show the counts that I need using codeigniter?
EX: Submitted to select 90 and 56
$this->db->where('atr_id', 90);
$this->db->or_where('atr_id', 56);
List_table
id | item_id | atr_id
---------------------------------------
1 | 1 | 56
2 | 1 | 90
3 | 2 | 56
4 | 2 | 90
5 | 2 | 92
The expected return would look like this.
item_id | active_attr | total_attr
----------------------------------------------
1 | 2 | 2 // active_attr (90,56) and total_attr (90 , 56)
2 | 2 | 3 // active_attr (90,56) and total_attr (90, 56, 92)
The active_attr counts the number of atr_id found (90, 56) in an item_id
And the total_attr counts the total number of atr_id of an item_id
Need really help here thanks guys...
active_attrresults in 2 foritem_id2?active_attrare 56 and 90 found