我的SQL查询是:

UPDATE REGISTRUDENT set qual=1
                WHERE studentolevelsubjects AS sls
                INNER JOIN courserequirements AS csreq ON sls.subject_id = csreq.subject_id
                WHERE sls.stud_id = '$stud_id' AND sls.grade_id>=csreq.min_grade AND sls.examno = '$examno' AND csreq.course_id = '$course_id'

我有问题比较两个不同的表格,如果注册人符合课程要求,我需要帮助
课程要求表
php - 比较两个表的数据关系-LMLPHP
学生在考试中通过的科目
php - 比较两个表的数据关系-LMLPHP
如果学生符合条件,我打算更新并设置qual=1
非常感谢

最佳答案

查询语法不正确。应该是

UPDATE REGISTRUDENT rs
JOIN studentolevelsubjects sls ON sls.some_column = rs.some_column //missing this JOIN
JOIN courserequirements csreq ON sls.subject_id = csreq.subject_id
AND sls.grade_id >= csreq.min_grade
WHERE sls.stud_id = '$stud_id'
AND sls.examno = '$examno'
AND csreq.course_id = '$course_id'
SET rs.qual = 1;

10-06 11:30