根据您提供的代码,可以做以下修改来获取user_company
表中的nickname作为creatorname:
$log_list = Db::name('notification_strategy')
->alias('stra')
->join('notification_receiver recv', 'FIND_IN_SET(recv.id, stra.receivers)', 'LEFT')
->join('user_company uc', 'uc.uid = stra.creator_id AND uc.company_id = stra.company_id', 'LEFT') // 添加联合查询
->whereIn('stra.department_id', $curdepartment_childrens)
->where($where)
->field('stra.*, GROUP_CONCAT(CASE WHEN recv.delete_time = 0 THEN recv.nickname ELSE NULL END) as receivers, uc.nickname as creatorname') // 添加uc.nickname别名
->order('stra.id desc')
->group('stra.id')
->paginate($data['limit']);
这样,在查询结果中会包含uc.nickname
字段,作为creatorname。请注意确保数据库中的表和字段名称正确无误。
内容由零声教学AI助手提供,问题来源于学员提问