我一直试图在我的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