What database are you using?
Sep 16, 2018
4
Level 2
Why `having` only worked on fields that are `group by` on laravel eloquent?
My script laravel eloquent like this :
$query = $this->item->select('a.*','b.attribute_code')
->from('items as a')
->join('attr_maps as b','b.number','=','a.number')
->groupBy('a.number');
foreach($param as $key => $value) {
$query = $query->having($key, '=', $value);
}
$query = $query->paginate(10);
If $param is array('number'=>'1234'), it works. No error
If $param is array('description'=>'test'), there exist error : Unknown column 'description' in 'having clause'
I tried all fields in the table items. Only the number field works. Apparently because the number field is group by
How can I solve this problem?
Please or to participate in this conversation.