If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I need a column for status that takes only one of two values, 0 or 1. I also need a way to flip the status (similar to binary bit compliment) from 0 to 1 or 1 to 0. Can I do this in MySql? Some thing like Update _tbl set flag=!flag?
The ! doesnt work, but ~ seems to work but is behaving funny. It flipped a b'0' to b'1' but could not flip a 1 back. Must be something I am doing wrong. Anyways I opted to use tinyint(1)
with "UPDATE daTable
SET status = CASE WHEN status = 1 THEN 0 ELSE 1 END" for flipping bits as r937 suggested.