How to toggle a field value in MySQL

Sometimes you don’t want to handle toggling a value in PHP or any other language, this is where IF becomes handy in MySQL.

You can simply toggle a value with the following UPDATE query.

Of course you can toggle any value you wish to toggle…
In the above example it is an TINYINT, but you can also toggle an ENUM if you want.

It is all up to you 🙂