我的表名学生 有字段student_id、house_id 等。以及科目、房屋、学生科目
我正在使用这个查询
SELECT students_subjects.student_id,students.house_id,students_subjects.subject_id,subjects.subject_name,students.rollno,students.first_name, students.last_name FROM
students_subjects LEFT JOIN students on students_subjects.student_id=students.id
LEFT JOIN subjects on students_subjects.subject_id=subjects.id WHERE students_subjects.class_years_section_id=1
这对我来说很好..
现在我也想从房屋表中获取房屋名称
我试过这个查询
SELECT students_subjects.student_id,students.house_id,houses.house_name, students_subjects.subject_id,subjects.subject_name,students.rollno,students.first_name, students.last_name FROM
students_subjects LEFT JOIN students on students_subjects.student_id=students.id
LEFT JOIN subjects on students_subjects.subject_id=subjects.id
在students.house_id=houses.id 上LEFT JOIN 房屋,其中students_subjects.class_years_section_id=1
AND students_subjects.school_session_id=1 AND students.is_active=1
它给了我 house_name = NULL
谁能告诉我如何获得房屋名称。使用连接查询
谢谢