【发布时间】:2021-03-10 02:37:50
【问题描述】:
我想在 Laravel 中对 Mysql 执行完全外连接。(我知道 Mysql 不支持完全外连接) 我想选择 id=$formId 的 table1 的所有字段和 table2 的一个字段。
DB::table('forms')
->leftJoin('answers',function($join) use($formId){
$join->on('forms.formid', '=' ,'answers.formid')
->where('forms.formid',$formId);
})
->select('forms.*','answers.uniqid')
->get();
但是 where 条件不起作用?
【问题讨论】:
-
->join('table2','table1.id', '=' ,'table2.id', 'left outer')
-
请参考这个链接你会找到答案。 stackoverflow.com/questions/52722604/…
-
这能回答你的问题吗? How to do a full join in Laravel Eloquent?