Php Laravel查询在id列上返回空id

Php Laravel查询在id列上返回空id,php,mysql,laravel,laravel-4,eloquent,Php,Mysql,Laravel,Laravel 4,Eloquent,好的,我编写了一些代码来从数据库中的某个左连接检索数据,在检索完这些数据后,我使用每个连接的id来填充一个模式。问题是它适用于一些已经检索到的数据。因为当我查看查询结果时,我注意到一些有效数据的id为null,而一些数据则为空 $someuser = DB::table('users') ->join('sometable', 'sometable.user_id', '=','users.id') ->leftjoin('sometable', 'users.id', '=',

好的,我编写了一些代码来从数据库中的某个左连接检索数据,在检索完这些数据后,我使用每个连接的id来填充一个模式。问题是它适用于一些已经检索到的数据。因为当我查看查询结果时,我注意到一些有效数据的id为null,而一些数据则为空

 $someuser =  DB::table('users')
->join('sometable', 'sometable.user_id', '=','users.id')
->leftjoin('sometable', 'users.id', '=', 'skills.user_id')
->leftjoin('sometable', 'users.id', '=','schools.user_id')
->leftjoin('sometable', 'users.id', '=', 'languages.user_id')
->leftjoin('sometable','users.id', '=', 'memberships.user_id')
->leftjoin('sometable', 'users.id', '=', 'convictions.user_id')
->leftjoin('sometable', 'users.id', '=', 'work_experiences.user_id')
->select('users.*','sometable.name as sometablename','sometable.*')
->where('users.first_name', '<>', '')->whereNotNull('users.id')
->orderBy('sometable.updated_at', 'DESC')->groupby('users.first-name')->distinct()->paginate(100); 
我说的很简单为什么我的id为空


我认为它不会向我显示超过1900的ID,因此如果用户超过1900,它会向我显示null

您正在从多个表中选择
*
。因为您也在加入,所以很可能没有什么可以加入的,所以您的数据库将这些列返回为null。特别选择您需要的id,并将其别名为不会被其他列覆盖的内容。

JSON是如何形成的?“数据”是否包含来自变量$cbuser的信息?Am laugh@user3158900我刚刚添加了一个别名,一个将要解决的问题,但你的权利它可以工作。这就是你想要的id的答案…太好了
{"total":966,"per_page":100,"current_page":1,"last_page":10,"from":1,"to":100,"data":[{"id":null, etc