由于删除了我的prevoius答案,我将以更详尽的方式重新发布答案。
我自己找到了它,也发现@ Jirka49的答案很有帮助。请参阅下面的链接。
See the last section in the webpage
因此,我们需要避免使用IN运算符。
因此,在查询期间创建一个临时表,其中包含问题,考试信息和问题信息(正号)的详细信息,无论学生正确回答了什么地方。
现在使用此表通过where子句更新响应表。
因此查询变为:
update responses,(select posmark,responses.testid,responses.qid,responses.stid from testinfo,responses,question
where testinfo.testid=responses.testid and responses.testid="<whatever testid>" and question.qid=responses.qid and question.cans=responses.response and question.subcode=testinfo.subcode and responses.stid='<for whichever student>')as temp
set responses.marks=temp.posmark where responses.qid=temp.qid and temp.testid=responses.testid and responses.stid=temp.stid;
对于负号也可以做类似的事情。并检查答案是否为空,简单查询将分配零标记。
,
在[这里] [1] https://forums.mysql.com/read.php?20,85816#msg-85816
中查看问题的答案
或看看这个:
UPDATE a
INNER JOIN b USING (id)
SET a.firstname='Pekka',a.lastname='Kuronen',b.companyname='Suomi Oy',companyaddress='Mannerheimtie 123,Helsinki Suomi'
WHERE a.id=1;
本文链接:https://www.f2er.com/3089337.html