This trick will work for both strings and numeric values. Basically with an update statement all you need to do is use an IF in the set portion of your query. In the below example I will toggle a string value of true
to false
and false
to true
.
SQL
update user_t
set enable_user = IF(enable_user='true', 'false', 'true')
where username='testuser';