MySQL uses TinyINT to serve as a boolean field. Given the possible options of 0 and 1, I decided that I'd flip values like this:
UPDATE table
SET boolean_field = ABS(boolean_field - 1)
WHERE Circle-K = 'Strange things are afoot'
So you either go 1 -> 0 -> ABS(0) = 0
or 0 -> -1 -> ABS(-1) = 1
now I'm curious if this is 开发者_如何学Cacceptable or horrifying to the real programmers?
/me is a beginner
Why not simply use:
UPDATE the_table SET boolean_field = NOT boolean_field WHERE ...
Makes your intention a lot easier to read
You can also use field
= 1 - field
or field
= ! field
精彩评论