Question: If multi thread concurrently query the following SQL to a database(postgresql):

```
UPDATE mytable SET n=n+1 WHERE n=0;

```

Whether or not 'n' will finally greater than 1

Answer: 
Update will take write lock, so no concurrent operation will actually happen on the table.

```
n will not be greater than 1.

```
> 
> `update mytable set n=n+1 where n=0;`
> 
> 
> Whether or not 'n' will finally greater than 1
> 
> 
> 

No it will not be "*greater than 1*" because adding `1` to `0` yields `1`.

So `n` will be **equal** to `1`, not "*greater than 1*".

And yes, it is *guaranteed* that all values that were previously 0 (zero) are 1 (one) after the update has finished without an error.