Welcome Guest, Not a member yet? Register   Sign In
Tip: toggling a boolean database column
#1

[eluser]richthegeek[/eluser]
Hi,

If you ever need to toggle a boolean database column between 1 and 0, but don't know what value is at the time, you can use the following query:
Code:
UPDATE `table` SET `column` = MOD( `column` + 1, 2 ) WHERE ...

It saves running a select query Smile

Hope that helps someone!


Messages In This Thread
Tip: toggling a boolean database column - by El Forum - 06-29-2009, 10:24 AM
Tip: toggling a boolean database column - by El Forum - 06-29-2009, 10:46 AM
Tip: toggling a boolean database column - by El Forum - 07-03-2009, 12:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB