I have two tables and I want to UPDATE
one table based on the values of another table.
With the help of the following SO-post I write a query:
query = f""" UPDATE table1
SET goal =
(SELECT table2.goal FROM table2
WHERE player = table2.player
AND opponent = table2.opponent
AND date = table2.date
AND competition = table2.competition
AND score = table2.score """
When I execute the query every row of table1
is affected with the same value for goal
. However, the desired process is that the query checks row-by-row if there are matching rows and, if so, update the column goal. What am I doing wrong?