I'm trying to do what I thought would be a simple table update with a sum from another table, but for some reason it only updates one row. Here is the relevant information from the tables:
games
gameplayer|points ---------------- John |5 Jim |3 John |3 Jim |4
playercareer
playercareername|playercareerpoints ----------------------------------- John |0 Jim |0
Now, ultimately, I would like the last table to look like this after starting the update:
playercareer
playercareername|playercareerpoints ----------------------------------- John |8 Jim |7
This query, I tried to update only the first line:
UPDATE playercareer SET playercareer.playercareerpoints = ( SELECT SUM(games.points) FROM games WHERE playercareer.playercareername=games.gameplayer )
It seems I can not find the answer to this question. Thank you in advance for your time and advice!
source share