我已經表名學生其領域student_id數據,house_id等。 和主題,房屋,students_subjectsMySql的連接查詢左連接
我使用此查詢
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
LEFT JOIN上students.house_id = houses.id 房子裏students_subjects.class_years_section_id = 1
AND students_subjects.school_session_id=1 AND students.is_active=1
,這讓我house_name = NULL
任何人都可以告訴我如何獲得房子名稱。使用連接查詢
感謝
這是常見的[MySQL的知識(HTTP://開發。 mysql.com/doc/refman/5.0/en/select.html)。你不能在'WHERE'語句之後加入'JOIN'。 – 2013-03-18 05:10:51