usually our data table may contain various state attributes, such as the blog table, we need to have a field to indicate whether it is public, whether there is a password set, whether the administrator blocked, whether it is pinned, and so on. Also encountered in the post OPS, planning requires adding new functionality and causing you to add new fields. This results in later maintenance difficulties, increased database size, and increased indexing. At this point, the use of bit arithmetic can be cleverly solved.
For example
--Public blog for status or Operation
UPDATE Blog SET status = Status | 1;
--Encrypt the blog for status or Operation
UPDATE Blog SET status = Status | 2;
--Block blog
UPDATE Blog SET status = Status | 4;
--Unlock blog
UPDATE Blog SET status = status ^ 4;
--Check all the blogs that are pinned
SELECT * from blog WHERE status & 8;
From for notes (Wiz)
MySQL uses bit arithmetic