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');

```
Later, after googling for a while, I learnt that the problem was caused by the `sql_mode` setting, and modified the configuration of **config/database.php** as `strict => false`.

Refer to: <https://stdworkflow.com/147/laravel-syntax-error-or-access-violation-1055-error>