BIT_AND()
BIT_AND() is a SQL function in the Aggregate Functions category. Performs a bitwise AND operation across all values in a group. Returns 1 only if all bits are 1. The syntax is BIT_AND(expression). It accepts expression. It returns bitwise result. A typical example: SELECT BIT_AND(permissions) FROM user_roles WHERE user_id = 1; -- Combined permissions mask (bitwise AND) SELECT BIT_OR(flags) FROM settings; -- Combined flags (bitwise OR) A close relative is COUNT(), which returns the number of rows (or non-NULL values) in a group. A close relative is SUM(), which returns the sum of all non-NULL values in a group. Works with numeric columns. A close relative is AVG(), which returns the average (mean) of all non-NULL values in a group. More about this category: Aggregation functions — COUNT, SUM, AVG, MIN, MAX, GROUP BY, HAVING. Related Aggregate Functions entries: COUNT(), SUM(), AVG(), MIN(), MAX(), GROUP_CONCAT() / LISTAGG(), STRING_AGG(), VARIANCE() / VAR_SAMP().