Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select `u`.*, count(t.empid) as totalassignedtask from `users` as `u` left join `tasks` as `t` on `t`.`empid` = `u`.`id` where `u`.`role` = 'user' group by `t`.`empid`
- $allemp = DB::table('users as u')
- ->leftJoin('tasks as t','t.empid','=','u.id')
- ->where('u.role','=','user')
- ->select('u.*',DB::raw('count(t.empid) as totalassignedtask'))
- ->groupBy('t.empid')
- ->get();
- 'strict' => true,
- strict => false
- $allemp = DB::table('users as u')
- ->join('tasks as t','t.empid','=','u.id')
- ->where('u.role','=','user')
- ->select('u.id','u.name','u.email',DB::raw('count(t.empid) as totalassignedtask'))
- ->groupBy('u.id','u.name','u.email')
- ->orderBy('totalassignedtask', 'asc')
- ->get();
Add Comment
Please, Sign In to add comment