Question: I want to use WhereIn and Groupby in the same query to fetch Result.

I've tried this:

```
$loadids=explode("#@*",$reciptdet->loading_id);
$loadingdatas=DB::table('loading')->groupBy('vehicle_no')->whereIn('id',$loadids)->get();

```

But I got this error message:

> 
> SQLSTATE[42000]: Syntax error or access violation: 1055 'sbrtpt.loading.id' isn't in GROUP BY (SQL: select \* from loading where id in (14, 15, 16) group by vehicle\_no)
> 
> 
>

Answer: 
I was having this problem also but after changing `'strict' => true`, to `'strict' => false`, the error disappeared.

You can find this setting in:

**config\database.php**

```
'mysql' => [
    ...
    'strict' => false,
    ...
]

```
I solve a similar issue with using group by by first getting the columns i needed to sort then use the group by.

```
$SampleData= DB::table('tableExampleName')->get(['col1','col2'])->groupBy('col3');

```

then you can dd() the values and check if they are the right grouping. You can all assign it and pass it into your view for further testing.

**Note**: This is using **Laravel 8**.