Как выполнить левое внешнее соединение с Laravel?Php

Кемеровские программисты php общаются здесь
Anonymous
Как выполнить левое внешнее соединение с Laravel?

Сообщение Anonymous »

Мне нужна информация из одной таблицы, и если есть совпадающая информация из другой таблицы.
это мой код

Код: Выделить всё

 $scoreObject = DB::table('responses')
->select('responses.id', 'responses.questions_id', 'responses.answer_id', 'responses.open_answer', 'responses.user_id',  'responses.scan_id',
'questions.question', 'questions.question_nr', 'questions.type', 'questions.totalsection_id',
'answers.id as answerID', 'answers.answer', 'answers.questions_id', 'answers.points'
)
->Join('answers as answers', 'responses.answer_id', '=', 'answers.id')
->Join('questions as questions', 'answers.questions_id', '=', 'questions.id')
->orderBy('questions.id', 'ASC')
->where('responses.scan_id', $scanid)
->where('responses.user_id', $userid)
->groupBy('questions.id')
->get();
Он возвращает все ответы, совпадающие с ответами (ответы.questions_id questions.id'). некоторые ответы не совпадают (поскольку нет ответов. Answer_id), но мне все равно нужна информация об ответах.
как я могу получить такое левое внешнее соединение в Laravel?

Подробнее здесь: https://stackoverflow.com/questions/284 ... th-laravel

Вернуться в «Php»