Jeff Butera <jbutera@linus.highpoint.edu> writes:
> UPDATE STUDENT_ANSWERS SET CORRECT=QA.CORRECT
> FROM QUESTION_ANSWERS QA,STUDENT_ANSWERS SA
> WHERE SA.CORRECT=null
> AND SA.QUESTIONS_ID=QA.QUESTIONS_ID
> AND SA.ANSWERS_ID=QA.ANSWERS_ID;
What you've got here is a three-way join between QUESTION_ANSWERS and
two instances of STUDENT_ANSWERS (the update target and the SA alias).
I doubt that's what you want. FROM in update should only be used for
*additional* tables. The target table has no alias and must be spelled
out:
UPDATE STUDENT_ANSWERS SET CORRECT=QA.CORRECT
FROM QUESTION_ANSWERS QA
WHERE STUDENT_ANSWERS.CORRECT=null
AND STUDENT_ANSWERS.QUESTIONS_ID=QA.QUESTIONS_ID
AND STUDENT_ANSWERS.ANSWERS_ID=QA.ANSWERS_ID;
regards, tom lane