Toggle a MySQL field between 0 and 1

PostDec 20th, 2010 | Comments (0)
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

Comments

There have been no comments

Post a comment

Name
URL
Email
Comment