Subject | Re: [firebird-support] toggle betweenn 0 and 1 |
---|---|
Author | Mark Rotteveel |
Post date | 2014-04-02T07:15:47Z |
On Wed, 2 Apr 2014 09:07:25 +0200, "checkmail" <check_mail@...>
wrote:
COLUMN = 1 - COLUMN (however this assumes that the column is NOT NULL and
always 1 or 0).
or with a simple CASE:
COLUMN = CASE COLUMN WHEN 1 THEN 0 ELSE 1 END
or a searched CASE:
COLUMN = CASE WHEN COLUMN = 1 THEN 0 ELSE 1 END
Mark
wrote:
> is there a simple way to toggle between 0 and 1?Sure:
>
> Update table set column NOT column where id = :id?
>
> If column = 1 - then set to 0, else set to 1.
COLUMN = 1 - COLUMN (however this assumes that the column is NOT NULL and
always 1 or 0).
or with a simple CASE:
COLUMN = CASE COLUMN WHEN 1 THEN 0 ELSE 1 END
or a searched CASE:
COLUMN = CASE WHEN COLUMN = 1 THEN 0 ELSE 1 END
Mark