I have 3 tables with the following structure:
Table User
- id
- name
- points
Table Group
- id
- name
- group_score
Table UsersGroups (association table)
- UserId
- GroupId
I'm trying to calculate the group_score - simply through adding all points of the users inside the group - for all groups.
i tried the following query
UPDATE `Group` SET group_score = (SELECT SUM(User.points) FROM User
                                    JOIN UsersGroups
                                    ON User.id = UsersGroups.UserId
                                    GROUP BY UsersGroups.GroupId)
which gives me OperationalError ('Subquery returns more than 1 row')
What am I doing wrong?
Thanks for the help!
 
     
    