Re: Increasing a column values partially
From: Axel Schwenke <axel.schwenke_at_gmx.de>
Date: Mon, 29 May 2017 19:30:24 +0200
Message-ID: <oghll0$nff$1_at_dont-email.me>
> START TRANSACTION;
> UPDATE table SET col = col + 1 where col >= 2 ORDER BY col;
> INSERT INTO table (col) VALUES (2);
> COMMIT;
Careful! That UPDATE might work or it might not. If there is no UNIQUE constraint on (col) then the ORDER BY clause is not necessary. If there however *is* such a constraint (the OP was not very clear here) then it would require an ORDER BY col DESC Received on Mon May 29 2017 - 19:30:24 CEST
Date: Mon, 29 May 2017 19:30:24 +0200
Message-ID: <oghll0$nff$1_at_dont-email.me>
On 29.05.2017 16:56, Lew Pitcher wrote:
>
> START TRANSACTION;
> UPDATE table SET col = col + 1 where col >= 2 ORDER BY col;
> INSERT INTO table (col) VALUES (2);
> COMMIT;
Careful! That UPDATE might work or it might not. If there is no UNIQUE constraint on (col) then the ORDER BY clause is not necessary. If there however *is* such a constraint (the OP was not very clear here) then it would require an ORDER BY col DESC Received on Mon May 29 2017 - 19:30:24 CEST