foodorders
foodorders_id foodorders_price foodorders_status
1 100 1
2 20 1
3 30 1
foodorders_detail
foodorders_detail_id(AI,PK) foodorders_id foodorders_foodname foodorders_lines
1 1 burgers 1
2 1 fries 2
3 1 chips 3
4 2 chips 1
5 3 drinks 1
5 3 bars 2
Чего я хочу: проверить, сколько строк с одинаковым foodorders_id и вернуть контроллеру
Что я пробовал:
$this->db->select('foodorders.foodorders_price,foodorders.status,COUNT(foodorders_detail.foodorders_lines');
$this->db->from('foodorders');
$this->db->join('foodorders_detail', 'foodorders_detail.foodorders_id = sales.foodorders_id', 'left');