I am looking for a solution/best practice to do a swap of values for a status flag.
The status INT(3) in mysql has a few values, and I’d like to be able to swap the LIVE and NOT_LIVE values around, without interrupting what other bitwise values are in there.
If it was a flag field, as in 0 or 1, it is easy:
'status' NOT 'status'
I was wondering if there was a way I could do a swap based on two values (x, y) – without too much code-logic, like the code above. Of course I may be dreaming, and just have to revert to a SELECT query, and if statement and an UPDATE…
any ideas?
so your values are 1 and 2, but you want bit-style flipping? that won’t work because 1 and 2 have different bits set!
try this: