Is there a way in MySQL to reverse a boolean field with one query?

后端 未结 4 1680
故里飘歌
故里飘歌 2021-01-01 11:06

I have a column in my table titled \'authorised\'. Its default is 0. It needs to be changed to 1 when the user is authorised, but it must be able to be reset to 0. I know I

4条回答
  •  长情又很酷
    2021-01-01 11:46

    UPDATE `users` SET `authorised` = NOT `authorised` WHERE id = 2
    

    This query will also work to negate the field, and is more inline with boolean syntax.

提交回复
热议问题