Mysql – Understanding the use of bitwise operators in MySQL

aggregatebitwise-comparisongroup byMySQL

Can someone explain the purpose of using bitwise operators(like BIT_OR) in MySQL queries. For example, if have a table such as following:

enter image description here

What is the purpose of aggregate operation like:

SELECT name, value FROM table GROUP BY name HAVING BIT_OR(value) = 0;

Best Answer

As an aggregate function the BIT_OR is evaluated as a bitwise OR of all the values in the group. If it equates to 0, none of the value have been set.