1 year ago

Leftjoin with groupby skips groupby

Posted 1 year ago by SkyCoder

I have Users that I want to count by left joining table for workouts and getting one row for each user.

$users->leftJoin('workout', function($join){
                        $join->on('', '=', 'workout.user_id')->where('workout.user_id', '>', 1)->groupBy('')->orderBy('');

First I dont get only one per workout, but for every workout. Like: w1 uid - 1 w2 uid - 2 w3 uid - 1

I get 3 users instead of 2...

Please sign in or create an account to participate in this conversation.