位置:首頁 > 數據庫 > MySQL教學 > MySQL bit_count()函數

MySQL bit_count()函數

BIT_COUNT(numeric_value)

BIT_COUNT()函數返回激活位 numeric_value 的位數。 下麵的例子說明了使用BIT_COUNT()函數返回激活位的數量的一係列數字:

mysql> SELECT
          BIT_COUNT(2) AS TWO,
          BIT_COUNT(4) AS FOUR,
          BIT_COUNT(7) AS SEVEN
+-----+------+-------+
| TWO | FOUR | SEVEN |
+-----+------+-------+
|   1 |    1 |     3 |
+-----+------+-------+
1 row in set (0.00 sec)