0

I have 2 tables: progress and student. progress has fields semester,idStudent,hasFirstAttestation and hasSecondAttestation. I need to get from progress those idStudent which have the maximum semester for student and both Attestation = 0 . Here is an example of my query, but it is not working:

SELECT progress.idStudent FROM monitoring.progress 
WHERE hasFirstAttestation = 0 AND hasSecondAttestation = 0 
AND semester = 
    (SELECT MAX(`semester`)
        FROM monitoring.progress WHERE progress.idStudent = student.idStudent);
4

2 回答 2

2

我想你忘了在 FROM 子句中提到连接表

SELECT idStudent 
FROM monitoring.progress 
WHERE hasFirstAttestation = 0 AND hasSecondAttestation = 0 
AND semester = (SELECT MAX(semester) FROM monitoring.progress, monitoring.student 
WHERE progress.idStudent = student.idStudent);
于 2013-06-12T22:21:04.307 回答
0
SELECT progress.idstudent 
FROM   monitoring.progress 
WHERE  hasfirstattestation = 0 
   AND hassecondattestation = 0 
   AND semester = (SELECT Max(`semester`) 
                   FROM   monitoring.progress,monitoring.student
                   WHERE  progress.idstudent = student.idstudent); 
于 2013-06-12T22:26:35.610 回答