Toggle a MySQL field between 0 and 1
Here's a simple example of how to toggle an integer (most often a tinyint in my case) field in MySQL between 0 and 1:
UPDATE table SET int_field=MOD(int_field+1,2) WHERE id=123
Here's a simple example of how to toggle an integer (most often a tinyint in my case) field in MySQL between 0 and 1:
UPDATE table SET int_field=MOD(int_field+1,2) WHERE id=123
could also do: UPDATE table SET int_field=!int_field WHERE id=123
tanks bunch. very usefull
Leave a Comment