Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.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 Laravel5.4中的连接查询_Php_Mysql_Laravel - Fatal编程技术网

Php Laravel5.4中的连接查询

Php Laravel5.4中的连接查询,php,mysql,laravel,Php,Mysql,Laravel,我有两张桌子。用户2。入围名单 现在,我得到了用户的详细信息,我也希望像用户是由我或不是入围的详细信息。如何使用join获取这些数据。 公共字段:user.id==入围者或user.id=入围者 目前,我仅通过此查询获取用户数据 $users = DB::table('user') ->select('user.Name','user.Age','user.FatherGotra','user.Profession','user.City','user.State','

我有两张桌子。用户2。入围名单

现在,我得到了用户的详细信息,我也希望像用户是由我或不是入围的详细信息。如何使用join获取这些数据。 公共字段:user.id==入围者或user.id=入围者

目前,我仅通过此查询获取用户数据

$users = DB::table('user')

         ->select('user.Name','user.Age','user.FatherGotra','user.Profession','user.City','user.State','user.AreYouManglik','user.DOB','user.ProfilePic','user.id')

                        ->where('ShowProfileOnMatrimony','YES')
                        ->where('Mobile','!=',$request->Mobile)
                        ->where('isVerified',1)
                        ->orderBy('user.id','DESC')
                        ->paginate(5);
尝试:

更多信息请点击此处:

试试:


更多信息请点击此处:

您能否明确说明您想加入哪些栏目?你的问题似乎有点含糊,其实我想得到的数据时,我得到的用户详细资料,该用户是由我或不是入围。有两列我们可以加入user.id==Shortlisted或user.id=ShortlistedBy,但我很困惑,因为我对php不熟悉。我该怎么做呢?看看我的答案,如果不是你所期望的,请告诉我你想加入哪些栏目?你的问题似乎有点含糊,其实我想得到的数据时,我得到的用户详细资料,该用户是由我或不是入围。有两列我们可以加入user.id==Shortlisted或user.id=ShortlistedBy,但我很困惑,因为我对php不熟悉。我该怎么做呢?看看我的答案,如果不是你所期望的,请告诉我。没有找到记录。我想如果用户没有被我列入短名单,一个键显示如下:isUserShortListed:True/false对不起,应该使用左连接。请看我混淆的答案。->leftJoin('Shortlisted','user.id','ShortlistedBy')->leftJoin('ShortlistedBy','user.id','ShortlistedBy','ShortlistedBy')。我的第二个表格是“入围名单”,科隆的名字是入围名单。我不能加入这个,但是当我用replace->leftjoin输入我的表名时(“短名单”…我得到了数据,但没有什么像是短名单或不是。它只显示UserDetails哦..你没有提到你的表被称为
短名单
。现在检查答案。如果不知道确切的列名和表名,我将很难得到正确的答案。也许用相关数据编辑你的问题a或用正确的表名和列名编辑我的答案?在顶部我提到我有两个表1.user 2.ShortList未找到记录。如果我没有将用户列入短名单,我希望一个键显示如下:isUserShortListed:True/False抱歉,应该使用左联接。请参阅我混淆的答案。->leftJoin('shortlisted',user.id',shortlisted'))->leftJoin('ShortlistedBy','user.id','ShortlistedBy','Shortlisted.ShortlistedBy')。我的第二个表是'shortlist',colum name是ShortlistedBy。我无法加入此表,但当我通过replace->leftJoin输入表名时(“短名单”…我得到了数据,但没有什么像是短名单或不是。它只显示UserDetails哦..你没有提到你的表被称为
短名单
。现在检查答案。如果不知道确切的列名和表名,我将很难得到正确的答案。也许用相关数据编辑你的问题a或者用正确的表格和列名编辑我的答案?在顶部我提到我有两个表格1.2.短名单
$users = DB::table('user')->select('user.Name','user.Age','user.FatherGotra','user.Profession','user.City','user.State','user.AreYouManglik','user.DOB','user.ProfilePic','user.id','shortlist.isShortlisted as isshortlist')
                    ->leftJoin('shortlist', 'user.id', 'Shortlisted')
                    ->leftJoin('shortlist as ShortlistedBy', 'user.id', 'shortlist.ShortlistedBy')
                    ->where('ShowProfileOnMatrimony','YES')
                    ->where('Mobile','!=',$request->Mobile)
                    ->where('isVerified',1)
                    ->orderBy('user.id','DESC')
                    ->paginate(5);