Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 5列它不包含在聚合函数或GROUP BY中_Php_Sql Server_Laravel - Fatal编程技术网

Php Laravel 5列它不包含在聚合函数或GROUP BY中

Php Laravel 5列它不包含在聚合函数或GROUP BY中,php,sql-server,laravel,Php,Sql Server,Laravel,我在尝试使用Laravel连接和分组id时在SQL中出错 列“推送通知。标题”在选择列表中无效,因为它不包含在聚合函数或分组依据子句中 我一直在尝试使用Max和Min,但仍然出现了一个错误 这是我的代码: $data = $this->model->select( 'push_notifications.id', 'push_notifications.title', 'push_notifications.description', 'push_notifications.att

我在尝试使用Laravel连接和分组id时在SQL中出错

列“推送通知。标题”在选择列表中无效,因为它不包含在聚合函数或分组依据子句中

我一直在尝试使用Max和Min,但仍然出现了一个错误

这是我的代码:

$data  = $this->model->select( 'push_notifications.id', 'push_notifications.title', 'push_notifications.description', 'push_notifications.attachment', 'push_notifications.feature_id', 'push_notifications.target_id', 'features.title as feature', 'push_notifications.end_at')
            ->join('push_notification_users', 'push_notification_users.push_notification_id', '=', 'push_notifications.id')
            ->join('push_notification_roles', 'push_notification_roles.push_notification_id', '=', 'push_notifications.id')
            ->leftJoin('features', 'features.id', '=', 'push_notifications.feature_id')
            ->where( 'push_notifications.notif_target', 'homepage' )
            ->where(function($role) {
                $roles = RoleUser::where('user_id',$this->user->id)->first();
                $role->where( 'push_notification_roles.deleted_at', null )
                    ->where( 'push_notification_roles.role_id', $roles->role_id );
             })
            ->orWhere(function($user) {
                $user->where( 'push_notification_users.deleted_at', null )
                    ->where( 'push_notification_users.user_id', $this->user->id );
             })
            ->where( 'push_notifications.end_at', '>',  Carbon::now()->toDateTimeString() )
            ->groupBy( 'push_notifications.id' )
            ->get();

如果你有任何解决办法,请告诉我,我将非常感激。谢谢

未找到“推送通知。标题”。可能有拼写错误。彻底检查。如果不是这样,请附上表格结构的屏幕截图,即推送通知

另一个原因是“push_notifications.id”必须有push_notifications.title的diff diff值,groupBy中单个“push_notifications.id”可以有多个“push_notifications.title”。只有选择“push_notifications.id”和其他一些独特的列才适用于您的情况


请参阅:

push_notifications.title列不是GROUP BY的一部分,请尝试添加此列。我已尝试添加所有列,但仍有错误