我希望这是有道理的,让我详细说明一下:
每一行都有一个测验程序的跟踪数据表。
QuestionID和AnswerID(每个都有一个表)。因此,由于存在一个错误,有一堆QuestionID设置为NULL,但是相关AnswerID的QuestionID在Answers表中。
因此,假设QuestionID为NULL,AnswerID为500,如果我们进入Answers表并找到AnswerID 500,则会出现一列带有QuestionID的列,该列应为NULL值所在的位置。
因此,基本上,我想将每个NULL QuestionID设置为等于在跟踪表中AnswerID的Answer行(与正在写入的NULL QuestionID相同的行)的Answers表中找到的QuestionID。
我该怎么做?
UPDATE QuestionTrackings
SET QuestionID = (need some select query that will get the QuestionID from the AnswerID in this row)
WHERE QuestionID is NULL AND ... ?
不知道如何使它从匹配的AnswerID中将QuestionID分配给QuestionID ...