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:
Using Query Builder
count()withgroupBy()doesn't return the correct number of rows, not considering the group by conditionI just made an example to show the problem
consider following table and code:
Output: