Toggle 1 And 0 Values In An Update MySQL Statement

Good thing MySQL has the IF() function that enables us to update a column by switching values to 0 if current value is 1 and vice versa in just 1 query.

This way, we do not have to waste resources by querying for the current value and then executing an update query.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *