Update table set column = Mod(column+1,2) where id = :id
From: [email protected] [mailto:[email protected]] On Behalf Of Mark Rotteveel Sent: Wednesday, April 2, 2014 10:16 AM To: [email protected] Subject: Re: [firebird-support] toggle betweenn 0 and 1 On Wed, 2 Apr 2014 09:07:25 +0200, "checkmail" <[email protected] <mailto:[email protected]> > wrote: > is there a simple way to toggle between 0 and 1? > > Update table set column NOT column where id = :id? > > If column = 1 - then set to 0, else set to 1. Sure: 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
