我想在Laravel中对Mysql执行完全外连接(我知道Mysql不支持完全外连接)我想选择table1 where id=$formId的所有字段和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条件不起作用吗?
发布于 2021-03-10 02:37:50
我改变了我的位置,它解决了我的问题。
DB::table('forms')
->leftJoin('answers',function($join) use($formId){
$join->on('forms.formid', '=' ,'answers.formid');
})
->where('forms.formid','109')
->select('forms.*','answers.uniqid')
->get();但是Laravel Doc在join函数中定位位置!
DB::table('users')
->join('contacts', function ($join) {
$join->on('users.id', '=', 'contacts.user_id')
->where('contacts.user_id', '>', 5);
})
->get();https://stackoverflow.com/questions/66548259
复制相似问题