UPDATE student as s
LEFT JOIN takes as t
ON s.ID = t.ID
LEFT JOIN course as c
ON t.course_id = c.course_id
SET s.tot_cred = s.tot_cred - c.credits
WHERE t.grade = 'F' OR t.grade IS NULL
I am trying to update tot_cred in student by subtracting the credit value of any class the student has failed, grade in takes relation = 'F', or is currently taking, grade in takes relation IS NULL.
The query above however sets tot_cred to NULL for any of the students who meet this criteria and I cannot figure out why.
I apologize if this has been asked before, I tried to search for something relevant but couldn't find many issues related to subtraction. I am new to stackoverflow. Thank you all for your help.