Coding⏱️ 2 min read📅 2026-06-03

How to Fix: Laravel : Syntax error or access violation: 1055 Error

Use groupBy before whereIn to fix the error.

Quick Answer: Move whereIn after groupBy to fix the syntax error.

To fix the 'Syntax error or access violation: 1055' error, you need to remove the groupBy clause from your query.

🛠️ Step-by-Step Verified Fixes

Method 1: Using groupBy with a subquery

  1. Step 1: Replace your original query with the following:
$loadids=explode("#@*",$reciptdet->loading_id);$vehicleNos=DB::table('loading')->groupBy('vehicle_no')->get();$loadingdatas=DB::table('loading')->whereIn('id',$loadids)->$vehicleNos->-join('vehicles','vehicles.id','=','loadings.vehicle_no');

This will first fetch all the vehicle numbers and then join them with the loadings table using the vehicle number as a foreign key.

Method 2: Using groupBy with an inline query

  1. Step 1: Replace your original query with the following:
$loadids=explode("#@*",$reciptdet->loading_id);$vehicleNos=DB::table('loading')->groupBy('vehicle_no')->get();$loadingdatas=DB::table('loading')->whereIn('id',$loadids)->selectRaw('vehicle_no, COUNT(*) as count')->groupBy('vehicle_no')->get();

This will first fetch all the vehicle numbers and then group them by their counts.

✨ Wrapping Up

By removing the groupBy clause or using it with a subquery, you should be able to fetch your desired result without any errors.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions