您好目前我有4個表在我的數據庫中:哪些是tb_student,tb_history,tb_section和tb_adviser。到目前爲止,我用這條線給我看給定學生的歷史:SQL語句4表連接
$qry_display = "SELECT
a.student_id, a.section_id, a.level, a.photo, a.address, a.father_occupation, a.father_phone, a.father_company, a.mother_occupation, a.mother_phone, a.mother_company,a.gpa,
b.fname, b.sex, b.lname, b.mname, b.birth_date, b.birth_place, b.address, b.father, b.father_degree, b.mother, b.mother_degree,
c.section_name, c.adviser_id
FROM tbl_er AS a
LEFT OUTER JOIN tbl_enroll AS b ON a.student_id = b.student_id
LEFT OUTER JOIN tbl_section AS c ON a.section_id = c.section_id
WHERE a.student_id=".$id." AND a.level='1st Year'";
我的主要問題是,現在我需要顯示這些其它信息顧問的姓氏。所以我在考慮放棄。需要注意的是tb_adviser只能通過adviser_id
LEFT OUTER JOIN tbl_adviser AS d ON a.student_id = c.adviser_id
連接到tb_section我加入這行之前有where語句。並會在我的SELECT字段中插入這一行。
d.lname_adviser
目前它不起作用。任何人都會對我的問題有所瞭解。
是的,謝謝它的作品。 –