SELECT
user_id,
project_id,
GROUP_CONCAT(project_specs_id) AS merged_specs_ids
FROM
zt_medication_specs_total
WHERE
specs_num_total < 5
GROUP BY
user_id, project_id;
laravel model 对应写法
return $this->select('user_id', 'project_id')
->selectRaw('GROUP_CONCAT(project_specs_id) AS merged_specs_ids')
->where('specs_num_total', '<', 5)
->groupBy('user_id', 'project_id')
->get();
}