I have a table of (700+ rows) with the following format:
id | session | win
------------------
1 1122 1
2 1122 1
3 1122 1
4 4559 1
5 4559 1
6 4559 1
7 4559 1
8 4559 1
Where win is either 1 or 0.
And session is not unique.
I want to update the group of rows that have the same session, and have all their win field set to 0 except for 1.
Goal:
id | session | win
------------------
1 1122 1
2 1122 0
3 1122 0
4 4559 1
5 4559 0
6 4559 0
7 4559 0
8 4559 0
Taking into consideration MySQL’s horrible syntax to perform updates, the only way I can think of doing this is:
It’d also possible to join instead of group by but I think a group by in this case would be faster.