可以直接写sql,不是一定要用thinkphp的组合语法啊。
M()->Query("select * from tableA a left join tableB b on a.id=b.id left join tableC c on b.id=c.id where c.id=1");// 类似这样
直接join
教师表 teacher
学生表 student
课程表 class
选课表 class_map
select * from teacher inner join class on class.teacher_id=teacher.id
left join class_map on class_map.class_id=class.id
left join student on student.id=map.student_id
where teacher.id=xxxxx