我想知道如何進行查詢,以顯示我需要使用codeigniter的計數?如何根據mysql中的位置來計數? php
EX:提交選擇90和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
的預期回報率應該是這樣的。
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)
的active_attr
計數atr_id
發現(90,56)在item_id
的數量和的item_id
atr_id
的total_attr
計數總數這裏真的需要幫助的感謝你們。 ..
請問您能澄清'item_id'的active_attr結果是2嗎? –
@DarshanMehta'active_attr'分別爲56和90找到 –
查看我的CI –