[Bug] Query Builder count() return wrong number with groupBy() #4306
Closed
Description
Using Query Builder count()
with groupBy()
doesn't return the correct number of rows, not considering the group by condition
I just made an example to show the problem
consider following table and code:
id | cat | desc |
---|---|---|
1 | 1 | abc |
2 | 1 | abc |
3 | 2 | abc |
$count = DB::table('product')
->where('cat', 1)
->groupBy('cat')
->count();
var_dump($count);
$count = DB::table('product')
->where('cat', 1)
->groupBy('cat')
->get();
var_dump(count($count));
Output:
int(2)
int(1)
Metadata
Assignees
Labels
No labels