Subject | AW: [firebird-support] toggle betweenn 0 and 1 |
---|---|
Author | checkmail |
Post date | 2014-04-02T08:52:49Z |
..good idea, thanks @ll
Von: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] Im Auftrag von Bogdan Mihalache
Gesendet: Mittwoch, 2. April 2014 09:26
An: firebird-support@yahoogroups.com
Betreff: RE: [firebird-support] toggle betweenn 0 and 1
Update table set column = Mod(column+1,2) where id = :id
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Mark Rotteveel
Sent: Wednesday, April 2, 2014 10:16 AM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] toggle betweenn 0 and 1
On Wed, 2 Apr 2014 09:07:25 +0200, "checkmail" <check_mail@...>
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