8 这是我的查询
$query = DB::table('hr_employees')
->select(DB::raw('hr_employees.id', 'hr_employees.employee_id_number', 'hr_employees.first_name', 'GROUP_CONCAT(hr_employee_daily_attendances.first_in SEPARATOR ', ') as tags'))
->join('hr_employee_daily_attendances', function ($join) {
$join->on('hr_employees.employee_id_number', '=', 'hr_employee_daily_attendances.employee_id_number');
});
return $query->paginate();
此查询仅返回hr_employee.id。 我需要获取所有指定的列值
有人可以帮助我吗? 预先感谢
答案 0 :(得分:0)
我通过此查询解决了该问题
$query = DB::table('hr_employees')
->select(DB::raw('hr_employees.id, hr_employees.employee_id_number, hr_employees.first_name, GROUP_CONCAT(hr_employee_daily_attendances.first_in SEPARATOR ", ") as month_days'))
->join('hr_employee_daily_attendances', function ($join) {
$join->on('hr_employees.employee_id_number', '=', 'hr_employee_daily_attendances.employee_id_number');
})
->groupBy('hr_employee_daily_attendances.employee_id_number')
->groupBy('hr_employees.id')
->groupBy('hr_employees.employee_id_number')
->groupBy('hr_employees.first_name');
return $query->paginate(10);
答案 1 :(得分:-1)
我从未在DB :: raw命令之外看到SELECT。尝试将SELECT语句移入DB :: raw