Level 104
You need to have a full group by, i.e. all non-aggregated columns should be in the GROUP BY clause.
Or, disable teh ONLY_FULL_GROUP_BY mode on the database server
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
There is my query function using fluent query builder. And I want to count id from some tables.
$my_jobs = DB::table('jobs')
->leftJoin('job_categories', 'jobs.cat_id', '=', 'job_categories.id')
->leftJoin('location', 'jobs.location_id', '=', 'location.id')
->leftJoin('jobtypes', 'jobs.jobtype', '=', 'jobtypes.id')
->leftJoin('users', 'jobs.user_id', '=', 'users.id')
->leftJoin('apply_jobs', 'jobs.id', '=', 'apply_jobs.job_id')
->select('jobs.title', 'jobs.salary_from', 'jobs.salary_to', 'jobs.job_slug', 'jobs.id', 'jobs.user_id', 'jobs.location_id', 'jobs.created_at', 'jobs.status', 'jobs.end_date', 'job_categories.category_name', 'location.state_name', 'jobtypes.jobtypes_name', 'users.first_name', 'users.last_name', 'users.verified', 'users.image_icon', DB::raw('COUNT(apply_jobs.job_id) as appliers'))
->orderBy('id','desc')->where(array('jobs.user_id'=> $user_id))->paginate(10);
And i have this error: "SQLSTATE[42000]: Syntax error or access violation: 1055 'free_jobs.jobs.title' isn't in GROUP BY (SQL: select `jobs`.`title`, `jobs`.`salary_from`, `jobs`.`salary_to`, `jobs`.`job_slug`, `jobs`.`id`, `jobs`.`user_id`, `jobs`.`location_id`, `jobs`.`created_at`, `jobs`.`status`, `jobs`.`end_date`, `job_categories`.`category_name`, `location`.`state_name`, `jobtypes`.`jobtypes_name`, `users`.`first_name`, `users`.`last_name`, `users`.`verified`, `users`.`image_icon`, COUNT(apply_jobs.job_id) as followers from `jobs` left join `job_categories` on `jobs`.`cat_id` = `job_categories`.`id` left join `location` on `jobs`.`location_id` = `location`.`id` left join `jobtypes` on `jobs`.`jobtype` = `jobtypes`.`id` left join `users` on `jobs`.`user_id` = `users`.`id` left join `apply_jobs` on `jobs`.`id` = `apply_jobs`.`job_id` where (`jobs`.`user_id` = 14) group by `apply_jobs`.`job_id` order by `id` desc limit 10 offset 0) ◀"
So how can i select count with query builder?
Thanks!
Please or to participate in this conversation.