Asked about Writing data safely

What is a race condition in a read-modify-write, and how do you prevent it?

An answer that works

Two transactions read the same value, each modifies it, and one write overwrites the other. Prevent it by doing the update atomically in one statement, locking the row before reading, or using optimistic concurrency with a version column.

Reading an answer is not being able to give one. The section that teaches this is Writing data safely, 3 hours of SQL & data access.

Learn this properly