我不明白为什么这个查询只获取1行但必须有34000行。没有错误生成。 $ fromDate =' 2015-10-01',$ toDate =' 2015-10-31' 和$ supervisorIdArray是一个展平数组。
$this->db->select('production.supervisor_id,production.employee_id,production.operation_id, SUM(production.quantity) as quantity,production_operation.operation_id,production_operation.rate');
$this->db->from('production');
$this->db->join('production_operation','production_operation.operation_id = production.operation_id', 'left');
$this->db->where('production.production_date >=',$fromDate);
$this->db->where('production.production_date <=',$toDate);
$this->db->where_in('production.supervisor_id',$supervisorIdArray);
$this->db->order_by('production.supervisor_id','ASC');
$this->db->order_by('production.employee_id','ASC');
$this->db->order_by('production.operation_id','ASC');
$query = $this->db->get();
$Rows = $query->num_rows();
答案 0 :(得分:2)
您正在使用组函数SUM
,因此它会产生一行。如果您想要多行添加group by
$this->db->group_by("production.supervisor_id");