I am trying to update a table based on the values in the table already.
Player Fixture
PlayerFId
FixtureFId
Availability
SelectedPosition
I want to update all rows where the player id is the same and take the values from a previous fixture id.
Example data
PlayerFId Fixture FId Availability SelectedPosition
1 1 N 2
1 2 U 0
2 1 A 3
2 2 U 0
I want to update all the rows for FixtureFId 2 with the relevant PlayerFId data for FixtureId 1.
End Result
PlayerFId Fixture FId Availability SelectedPosition
1 1 N 2
1 2 N 2
2 1 A 3
2 2 N 3
I have tried using this SQL but it doesn't map the PlayerFId values correctly
UPDATE player_fixture
SET
Availability = (SELECT Availability FROM player_fixture WHERE FixtureFId = 1),
SelectedPosition = (SELECT SelectedPosition FROM player_fixture WHERE FixtureFId = 1)
WHERE FixtureFId = 2