jhutto

Multiple Joins with Where's

Posted 8 months 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.