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: 
Without modifiying `config\database.php` file
=============================================

**Set `'strict' => false`** in the `config\database.php` could be a **security issue**. So, a simple Laravel solution could be **first call `get()` and then `groupBy('vehicle_no)`**:

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

```
update `config/database.php`

set:

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

```

instead of:

```
'mysql' => [
     'strict' => true,
],

```

and don't forget to clear cache:

```
php artisan config:cache

```