我一直試圖在我的SELECT
中使用AND
,但是出現錯誤。如何使用選擇AND
什麼可能是我應該編寫代碼的正確方法?
的代碼是:
$sel=mysql_query("SELECT * from student, subject, studentmark
where student.username='$name' AND studentmark.student_id='$name' AND studentmark.YEAR='$ya' AND studentmark.Term='FIRST' AND studentmark.Term='SECOND' AND studentmark.Term='THIRD' AND subject.code=studentmark.code AND student.username=studentmark.student_id");
你得到的錯誤是什麼? – Nerdwood
studentmark.Term ='FIRST'and studentmark.Term ='SECOND'and studentmark.Term ='THIRD'。這種情況將永遠不會發生,你將不會得到任何回報。此外,您需要使用JOIN而不是以下內容:student.username = studentmark.student_id – RyanB
也許這些AND應該是OR。 (並且在括號內。) – jarlh