I do sampling from a DB. The part of the code during which the error occurs:

if (count($rgColl) > 0) { $this->projects->join('object_collection', function($join) use($rgColl) { $join->on('object_collection.object_id', '=', 'objects.id'); if (count($rgColl) == 1) { $join->where('object_collection.collection_id', '=', $rgColl[0]); } else { $join->whereIn('object_collection.collection_id', $rgColl); } }); $this->select[] = 'object_collection.object_id'; $this->select[] = 'object_collection.collection_id'; $this->group[] = 'object_collection.object_id'; } 

If $rgColl 1 item, then the result is returned normally.
If $join->whereIn('object_collection.collection_id', $rgColl); , it gives an error:

SQLSTATE [42000]: Syntax error or access violation: 1064 SQL syntax; check my server for syntax to use near? where objects . category_id =? group by object_parameters_size .`object_id 'at line 1

I take the request code generated by Laravel v5 and simply execute it in MySQL Workbench - the data is returned.

The full query looks like this:

 SELECT `objects`.`id`, `objects`.`ord`, `objects`.`title`, `objects`.`art`, `objects`.`code`, `object_parameters_size`.`object_id`, `object_parameters_size`.`parameter_id`, `object_parameters_size`.`valint`, `object_collection`.`object_id`, `object_collection`.`collection_id` FROM `objects` INNER JOIN `object_parameters` AS `object_parameters_size` ON `object_parameters_size`.`object_id` = `objects`.`id` AND `object_parameters_size`.`parameter_id` = 1 AND `object_parameters_size`.`valint` > 0 AND `object_parameters_size`.`valint` < 500 INNER JOIN `object_collection` ON `object_collection`.`object_id` = `objects`.`id` AND `object_collection`.`collection_id` IN (38,15,39,40,41) WHERE `objects`.`category_id` = 1 GROUP BY `object_parameters_size`.`object_id` , `object_collection`.`object_id` ORDER BY `objects`.`ord` ASC 

Some kind of anomaly is obtained.

    1 answer 1

    Elementary googling:

    https://github.com/laravel/framework/issues/4412 https://stackoverflow.com/questions/26913776/laravel-4-add-wherein-clause-to-a-join-condition

    It is not possible to make join-> whereIn ()