I have a table with 2 column: id and count. Count is exclusive OR (only one of them can be 1 at same time). I need to update a row with count = 1 and need to put the previous count 1 at 0.
I think two strategies:
1) Do a select on the table, find the row at 1. Update it at 0. Update the row that i want be at 1.
2) Global update the table at count 0. Update the row that i want be at 1.
In the first case i do 3 query but "small". In the second case i do 2 query but one of them is "big".
Which strategy is better?