I am using microsoft access and I have a total of 3 tables: Credits, Orders, and Books which are shown below. I need to create an update query that updates the existing Number of Credits for each student based on the books that they have ordered and the corresponding amount of credits for each book.
For instance, student B-17 starts with 24 credits but after the update query it should change the student's credits to 32.
Credits Table
Student ID Number of Credits
B-17 24
F-59 30
Orders Table
Student ID Book ID
B-17 101
B-17 102
F-59 101
F-59 105
Books Table
Book ID Book Title Credits
101 English I 3
102 Accounting 5
105 Calculus 5
This is what I am trying but I keep getting a syntax error in Access.
UPDATE Credits c
SET [Number of Credits] = [Number of Credits] + (SELECT SUM(Credits)
FROM Orders o, Books b ON
o.[Book ID] = b.[Book ID] WHERE
c.[Student ID] = o.[Student ID])
WHERE c.[Student ID] = o.[Student ID];