Multiple Joins with Where's

Posted 1 month ago by jhutto

I have a query that I can't get to work. It works if I take out the second join with instructors

$SemesterCourse = DB::table('coursesemester')
            ->join('somascourses', 'coursesemester.id', '=', 'somascourses.SemesterID')
            ->join('instructors', 'somascourses.SemesterID', '=', 'instructors.id')
            ->where([
                ['coursesemester.id', $semesterid],
                ['somascourses.id', $courseid],])
            ->get();

This mysql statement is working on the database

SELECT * FROM coursesemester
INNER JOIN somascourses ON coursesemester.id = somascourses.SemesterID
INNER JOIN instructors ON somascourses.Instructorid = instructors.id
WHERE coursesemester.id = 31 AND somascourses.id = 345

So, it seems to the the double Join that kills the query

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.