MySQL反向值(NOT运算符)

Is there a function is MySQL that automatically UPDATEs the value to the opposite one (something like ! NOT operator in php), without fetching the data, changing the value and inserting it again.

Also, if this helps, i need it only for zeroes and ones if there is any other, simpler way.

!0 = 1
!1 = 0

For only 0 and 1 you can do

UPDATE myTable SET myValue= 1 - myValue    // 1 becomes 0, 0 becomes 1.

If you want to include -1 in the scheme as well, you can do

UPDATE myTable SET myValue= 1 - ABS(myValue)    // 1 and -1 become 0, 0 becomes 1.

you can use:

UPDATE `your_table` SET `your_boolean_field` = NOT your_boolean_field;

You can try:

UPDATE table_name
SET column1=1-column1

If column1 is 1, than it will be 0, because 1-1=0, and if it's 0, then 1-0=1.

Try this for 0 and 1 only

UPDATE table_name SET myValue = IF (myValue, 0, 1);

Check here Demo